Skip to content

Commit 6c81f21

Browse files
committedJul 29, 2024··
First commit
0 parents  commit 6c81f21

File tree

17 files changed

+302
-0
lines changed

17 files changed

+302
-0
lines changed
 

‎.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @jenkinsci/first-plugin-developers

‎.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates
2+
3+
version: 2
4+
updates:
5+
- package-ecosystem: maven
6+
directory: /
7+
schedule:
8+
interval: monthly
9+
- package-ecosystem: github-actions
10+
directory: /
11+
schedule:
12+
interval: monthly

‎.github/release-drafter.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_extends: .github
2+
tag-template: first-$NEXT_MINOR_VERSION
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# More information about the Jenkins security scan can be found at the developer docs: https://www.jenkins.io/redirect/jenkins-security-scan/
2+
3+
name: Jenkins Security Scan
4+
on:
5+
push:
6+
branches:
7+
- "master"
8+
- "main"
9+
pull_request:
10+
types: [ opened, synchronize, reopened ]
11+
workflow_dispatch:
12+
13+
permissions:
14+
security-events: write
15+
contents: read
16+
actions: read
17+
18+
jobs:
19+
security-scan:
20+
uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2
21+
with:
22+
java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate.
23+
java-version: 11 # What version of Java to set up for the build.

‎.github/workflows/release-drafter.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Automates creation of Release Drafts using Release Drafter
2+
# More Info: https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
update_release_draft:
12+
runs-on: ubuntu-latest
13+
steps:
14+
# Drafts your next Release notes as Pull Requests are merged into the default branch
15+
- uses: release-drafter/release-drafter@v6
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
target
2+
3+
# mvn hpi:run
4+
work
5+
6+
# IntelliJ IDEA project files
7+
*.iml
8+
*.iws
9+
*.ipr
10+
.idea
11+
12+
# Eclipse project files
13+
.settings
14+
.classpath
15+
.project

‎.mvn/extensions.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 https://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
2+
<extension>
3+
<groupId>io.jenkins.tools.incrementals</groupId>
4+
<artifactId>git-changelist-maven-extension</artifactId>
5+
<version>1.7</version>
6+
</extension>
7+
</extensions>

‎.mvn/maven.config

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-Pconsume-incrementals
2+
-Pmight-produce-incrementals

‎Jenkinsfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
See the documentation for more options:
3+
https://github.com/jenkins-infra/pipeline-library/
4+
*/
5+
buildPlugin(
6+
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
7+
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
8+
configurations: [
9+
[platform: 'linux', jdk: 21],
10+
[platform: 'windows', jdk: 17],
11+
])

‎LICENSE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License
2+
3+
Copyright 2024
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# first
2+
3+
## Introduction
4+
5+
TODO Describe what your plugin does here
6+
7+
## Getting started
8+
9+
TODO Tell users how to configure your plugin here, include screenshots, pipeline examples and
10+
configuration-as-code examples.
11+
12+
## Issues
13+
14+
TODO Decide where you're going to host your issues, the default is Jenkins JIRA, but you can also enable GitHub issues,
15+
If you use GitHub issues there's no need for this section; else add the following line:
16+
17+
Report issues and enhancements in the [Jenkins issue tracker](https://issues.jenkins.io/).
18+
19+
## Contributing
20+
21+
TODO review the default [CONTRIBUTING](https://github.com/jenkinsci/.github/blob/master/CONTRIBUTING.md) file and make sure it is appropriate for your plugin, if not then add your own one adapted from the base file
22+
23+
Refer to our [contribution guidelines](https://github.com/jenkinsci/.github/blob/master/CONTRIBUTING.md)
24+
25+
## LICENSE
26+
27+
Licensed under MIT, see [LICENSE](LICENSE.md)
28+

‎pom.xml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.jenkins-ci.plugins</groupId>
7+
<artifactId>plugin</artifactId>
8+
<version>4.78</version>
9+
<relativePath />
10+
</parent>
11+
12+
<groupId>io.jenkins.plugins</groupId>
13+
<artifactId>first</artifactId>
14+
<version>${revision}${changelist}</version>
15+
<packaging>hpi</packaging>
16+
17+
<name>TODO Plugin</name>
18+
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
19+
<licenses>
20+
<license>
21+
<name>MIT License</name>
22+
<url>https://opensource.org/license/mit/</url>
23+
</license>
24+
</licenses>
25+
<scm child.scm.connection.inherit.append.path="false" child.scm.developerConnection.inherit.append.path="false" child.scm.url.inherit.append.path="false">
26+
<connection>scm:git:https://github.com/${gitHubRepo}</connection>
27+
<developerConnection>scm:git:https://github.com/${gitHubRepo}</developerConnection>
28+
<tag>${scmTag}</tag>
29+
<url>https://github.com/${gitHubRepo}</url>
30+
</scm>
31+
<properties>
32+
<revision>1.0</revision>
33+
<changelist>-SNAPSHOT</changelist>
34+
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
35+
<jenkins.version>2.414.3</jenkins.version>
36+
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
37+
<spotless.check.skip>false</spotless.check.skip>
38+
</properties>
39+
40+
<dependencyManagement>
41+
<dependencies>
42+
<dependency>
43+
<groupId>io.jenkins.tools.bom</groupId>
44+
<artifactId>bom-2.414.x</artifactId>
45+
<version>2857.v01a_0144eb_20b_</version>
46+
<type>pom</type>
47+
<scope>import</scope>
48+
</dependency>
49+
</dependencies>
50+
</dependencyManagement>
51+
52+
<repositories>
53+
<repository>
54+
<id>repo.jenkins-ci.org</id>
55+
<url>https://repo.jenkins-ci.org/public/</url>
56+
</repository>
57+
</repositories>
58+
<pluginRepositories>
59+
<pluginRepository>
60+
<id>repo.jenkins-ci.org</id>
61+
<url>https://repo.jenkins-ci.org/public/</url>
62+
</pluginRepository>
63+
</pluginRepositories>
64+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package io.jenkins.plugins.sample;
2+
3+
import hudson.Extension;
4+
import hudson.ExtensionList;
5+
import hudson.util.FormValidation;
6+
import jenkins.model.GlobalConfiguration;
7+
import org.apache.commons.lang.StringUtils;
8+
import org.kohsuke.stapler.DataBoundSetter;
9+
import org.kohsuke.stapler.QueryParameter;
10+
11+
/**
12+
* Example of Jenkins global configuration.
13+
*/
14+
@Extension
15+
public class SampleConfiguration extends GlobalConfiguration {
16+
17+
/** @return the singleton instance */
18+
public static SampleConfiguration get() {
19+
return ExtensionList.lookupSingleton(SampleConfiguration.class);
20+
}
21+
22+
private String label;
23+
24+
public SampleConfiguration() {
25+
// When Jenkins is restarted, load any saved configuration from disk.
26+
load();
27+
}
28+
29+
/** @return the currently configured label, if any */
30+
public String getLabel() {
31+
return label;
32+
}
33+
34+
/**
35+
* Together with {@link #getLabel}, binds to entry in {@code config.jelly}.
36+
* @param label the new value of this field
37+
*/
38+
@DataBoundSetter
39+
public void setLabel(String label) {
40+
this.label = label;
41+
save();
42+
}
43+
44+
public FormValidation doCheckLabel(@QueryParameter String value) {
45+
if (StringUtils.isEmpty(value)) {
46+
return FormValidation.warning("Please specify a label.");
47+
}
48+
return FormValidation.ok();
49+
}
50+
}

‎src/main/resources/index.jelly

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?jelly escape-by-default='true'?>
2+
<div>
3+
TODO
4+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?jelly escape-by-default='true'?>
3+
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
4+
<f:section title="${%Sample Plugin}">
5+
<f:entry field="label" title="${%Label}">
6+
<f:textbox/>
7+
</f:entry>
8+
</f:section>
9+
</j:jelly>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
Explanation of what the label does.
3+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package io.jenkins.plugins.sample;
2+
3+
import static org.junit.Assert.*;
4+
5+
import org.htmlunit.html.HtmlForm;
6+
import org.htmlunit.html.HtmlTextInput;
7+
import org.junit.Rule;
8+
import org.junit.Test;
9+
import org.jvnet.hudson.test.JenkinsSessionRule;
10+
11+
public class SampleConfigurationTest {
12+
13+
@Rule
14+
public JenkinsSessionRule sessions = new JenkinsSessionRule();
15+
16+
/**
17+
* Tries to exercise enough code paths to catch common mistakes:
18+
* <ul>
19+
* <li>missing {@code load}
20+
* <li>missing {@code save}
21+
* <li>misnamed or absent getter/setter
22+
* <li>misnamed {@code textbox}
23+
* </ul>
24+
*/
25+
@Test
26+
public void uiAndStorage() throws Throwable {
27+
sessions.then(r -> {
28+
assertNull("not set initially", SampleConfiguration.get().getLabel());
29+
HtmlForm config = r.createWebClient().goTo("configure").getFormByName("config");
30+
HtmlTextInput textbox = config.getInputByName("_.label");
31+
textbox.setText("hello");
32+
r.submit(config);
33+
assertEquals(
34+
"global config page let us edit it",
35+
"hello",
36+
SampleConfiguration.get().getLabel());
37+
});
38+
sessions.then(r -> {
39+
assertEquals(
40+
"still there after restart of Jenkins",
41+
"hello",
42+
SampleConfiguration.get().getLabel());
43+
});
44+
}
45+
}

0 commit comments

Comments
 (0)
Please sign in to comment.