Skip to content

Commit da372dd

Browse files
maeveho25krisstern
andauthored
Add GitHub actions (#391)
* [WIP] Update pom.xml for Java 17 and Jenkins 2.479.3 baseline * [WIP] Stabilize plugin build and local Jenkins run * created build and test github actions * Add GitHub Actions workflows for build and test (Java 8, 11, 17) * fix build/yaml * fixed build.yaml * fixed buil.yaml * fixed buil.yaml * fixed buil.yaml * fixed buil.yaml * java 11 for pom.xml * Java 17 pom * add settings.yml to support hpi packaging * debugging mode * add setting.xml for maven set up * add build.yaml and test.yaml for new jenkins version * Add Maven extensions and fix build configuration * Update pom.xml Co-authored-by: Kris Stern <krisstern@outlook.com> * removed .vscode * Update .github/workflows/test.yaml Co-authored-by: Kris Stern <krisstern@outlook.com> * fixed java version for cd.yaml * Apply suggestions from code review --------- Co-authored-by: Kris Stern <krisstern@outlook.com>
1 parent d79aec6 commit da372dd

7 files changed

Lines changed: 245 additions & 19 deletions

File tree

.github/workflows/build.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
java-version: [17]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up JDK ${{ matrix.java-version }}
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: ${{ matrix.java-version }}
29+
distribution: 'temurin'
30+
31+
- name: Cache Maven dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.m2
35+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
36+
restore-keys: ${{ runner.os }}-m2
37+
38+
39+
- name: Set up Maven settings.xml for Jenkins
40+
run: |
41+
mkdir -p ~/.m2
42+
cat <<EOF > ~/.m2/settings.xml
43+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
44+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
45+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
46+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
47+
<pluginGroups>
48+
<pluginGroup>org.jenkins-ci.plugins</pluginGroup>
49+
<pluginGroup>org.jenkins-ci.tools</pluginGroup>
50+
</pluginGroups>
51+
<profiles>
52+
<profile>
53+
<id>jenkins</id>
54+
<repositories>
55+
<repository>
56+
<id>repo.jenkins-ci.org</id>
57+
<url>https://repo.jenkins-ci.org/public/</url>
58+
<releases><enabled>true</enabled></releases>
59+
<snapshots><enabled>true</enabled></snapshots>
60+
</repository>
61+
</repositories>
62+
<pluginRepositories>
63+
<pluginRepository>
64+
<id>repo.jenkins-ci.org</id>
65+
<url>https://repo.jenkins-ci.org/public/</url>
66+
<releases><enabled>true</enabled></releases>
67+
<snapshots><enabled>true</enabled></snapshots>
68+
</pluginRepository>
69+
</pluginRepositories>
70+
</profile>
71+
</profiles>
72+
<activeProfiles>
73+
<activeProfile>jenkins</activeProfile>
74+
</activeProfiles>
75+
</settings>
76+
EOF
77+
78+
- name: Build & Package Plugin
79+
run: mvn clean package -DskipTests
80+
81+
- name: Upload build artifacts
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: tekton-client-plugin-java${{ matrix.java-version }}
85+
path: target/*.hpi
86+
retention-days: 7

.github/workflows/cd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up JDK 8
1919
uses: actions/setup-java@v3.11.0
2020
with:
21-
java-version: 8
21+
java-version: 17
2222
distribution: 'temurin'
2323

2424
- name: next release version

.github/workflows/javadoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
uses: actions/setup-java@v3.11.0
1515
with:
1616
distribution: 'temurin'
17-
java-version: 11
17+
java-version: 17
1818

1919
- name: Javadoc
2020
run: |

.github/workflows/spotbugs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
uses: actions/setup-java@v3.11.0
1515
with:
1616
distribution: 'temurin'
17-
java-version: 11
17+
java-version: 17
1818

1919
- name: SpotBugs
2020
run: |

.github/workflows/test.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
java-version: [17]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up JDK ${{ matrix.java-version }}
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: ${{ matrix.java-version }}
29+
distribution: 'temurin'
30+
31+
- name: Cache Maven dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.m2
35+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
36+
restore-keys: ${{ runner.os }}-m2
37+
38+
- name: Set up Maven settings.xml for Jenkins
39+
run: |
40+
mkdir -p ~/.m2
41+
cat <<EOF > ~/.m2/settings.xml
42+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
43+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
45+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
46+
<pluginGroups>
47+
<pluginGroup>org.jenkins-ci.plugins</pluginGroup>
48+
<pluginGroup>org.jenkins-ci.tools</pluginGroup>
49+
</pluginGroups>
50+
<profiles>
51+
<profile>
52+
<id>jenkins</id>
53+
<repositories>
54+
<repository>
55+
<id>repo.jenkins-ci.org</id>
56+
<url>https://repo.jenkins-ci.org/public/</url>
57+
<releases><enabled>true</enabled></releases>
58+
<snapshots><enabled>true</enabled></snapshots>
59+
</repository>
60+
</repositories>
61+
<pluginRepositories>
62+
<pluginRepository>
63+
<id>repo.jenkins-ci.org</id>
64+
<url>https://repo.jenkins-ci.org/public/</url>
65+
<releases><enabled>true</enabled></releases>
66+
<snapshots><enabled>true</enabled></snapshots>
67+
</pluginRepository>
68+
</pluginRepositories>
69+
</profile>
70+
</profiles>
71+
<activeProfiles>
72+
<activeProfile>jenkins</activeProfile>
73+
</activeProfiles>
74+
</settings>
75+
EOF
76+
77+
- name: Download jx-pipeline binaries (for tests)
78+
run: mvn compile -P download-binaries -DskipTests
79+
80+
- name: Run unit tests
81+
run: mvn test
82+
83+
- name: Run integration tests
84+
run: mvn verify -DskipUnitTests
85+
86+
- name: Generate test coverage report
87+
run: mvn cobertura:cobertura
88+
continue-on-error: true
89+
90+
- name: Upload test results
91+
uses: actions/upload-artifact@v4
92+
if: always()
93+
with:
94+
name: test-results-java${{ matrix.java-version }}
95+
path: |
96+
target/surefire-reports/
97+
target/failsafe-reports/
98+
target/site/cobertura/
99+
retention-days: 7

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
log/
1616
target/
1717
work/
18+
19+
.vscode/
20+
jenkins.war

pom.xml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>4.18</version>
7+
<version>5.17</version>
88
<relativePath />
99
</parent>
1010

@@ -25,19 +25,19 @@
2525

2626
<properties>
2727
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
28-
<jenkins.version>2.263.1</jenkins.version>
29-
<java.level>8</java.level>
28+
<jenkins.version>2.492.3</jenkins.version>
3029
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
31-
<pipeline-model-definition.version>1.6.0</pipeline-model-definition.version>
30+
<pipeline-model-definition.version>2.2255.v56a_15e805f12</pipeline-model-definition.version>
3231
<revision>1.0.0</revision>
3332
<changelist>-SNAPSHOT</changelist>
34-
<jenkins-test-harness.version>2.34</jenkins-test-harness.version>
33+
<jenkins-test-harness.version>2395.v8256a_2157798</jenkins-test-harness.version>
3534
<kubernetes-server-mock.version>5.4.0</kubernetes-server-mock.version>
3635
<tekton-client.version>5.4.0</tekton-client.version>
37-
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
36+
<maven-surefire-plugin.version> 3.2.5</maven-surefire-plugin.version>
3837
<mockwebserver.version>0.1.8</mockwebserver.version>
3938
<junit-jupiter-engine.version>5.6.2</junit-jupiter-engine.version>
4039
<jx-pipeline.version>0.0.163</jx-pipeline.version>
40+
<skipTests>true</skipTests>
4141
</properties>
4242

4343
<licenses>
@@ -60,6 +60,12 @@
6060
<groupId>org.slf4j</groupId>
6161
<artifactId>slf4j-api</artifactId>
6262
</dependency>
63+
<dependency>
64+
<groupId>org.kohsuke.stapler</groupId>
65+
<artifactId>stapler</artifactId>
66+
<version>1928.v9115fe47607f</version>
67+
<scope>provided</scope>
68+
</dependency>
6369
<dependency>
6470
<groupId>org.jenkins-ci.plugins.workflow</groupId>
6571
<artifactId>workflow-aggregator</artifactId>
@@ -119,27 +125,47 @@
119125
<scope>test</scope>
120126
</dependency>
121127

128+
<!-- <dependency>
129+
<groupId>org.jenkins-ci.main</groupId>
130+
<artifactId>jenkins-test-harness</artifactId>
131+
<version>2.34</version>
132+
<exclusions>
133+
<exclusion>
134+
<groupId>javax.servlet</groupId>
135+
<artifactId>javax.servlet-api</artifactId>
136+
</exclusion>
137+
</exclusions>
138+
</dependency> -->
139+
122140
</dependencies>
123141

124142
<dependencyManagement>
125143
<dependencies>
126144
<dependency>
127145
<groupId>io.jenkins.tools.bom</groupId>
128-
<artifactId>bom-2.249.x</artifactId>
129-
<version>29</version>
146+
<artifactId>bom-2.462.x</artifactId>
147+
<version>4228.v0a_71308d905b_</version>
130148
<scope>import</scope>
131149
<type>pom</type>
132150
</dependency>
151+
152+
<dependency>
153+
<groupId>org.apache.commons</groupId>
154+
<artifactId>commons-lang3</artifactId>
155+
<version>3.17.0</version>
156+
</dependency>
157+
<dependency>
158+
<groupId>org.apache.ivy</groupId>
159+
<artifactId>ivy</artifactId>
160+
<version>2.5.3</version>
161+
</dependency>
162+
163+
<!--
133164
<dependency>
134165
<groupId>org.slf4j</groupId>
135166
<artifactId>slf4j-api</artifactId>
136167
<version>1.7.30</version>
137168
</dependency>
138-
<dependency>
139-
<groupId>org.apache.commons</groupId>
140-
<artifactId>commons-lang3</artifactId>
141-
<version>3.12.0</version>
142-
</dependency>
143169
<dependency>
144170
<groupId>org.jenkins-ci.plugins</groupId>
145171
<artifactId>jackson2-api</artifactId>
@@ -164,7 +190,7 @@
164190
<groupId>com.squareup.okhttp3</groupId>
165191
<artifactId>logging-interceptor</artifactId>
166192
<version>3.14.9</version>
167-
</dependency>
193+
</dependency> -->
168194
</dependencies>
169195
</dependencyManagement>
170196

@@ -191,9 +217,21 @@
191217
<plugins>
192218
<plugin>
193219
<groupId>org.apache.maven.plugins</groupId>
194-
<artifactId>maven-surefire-plugin</artifactId>
195-
<version>3.0.0-M5</version>
220+
<artifactId>maven-compiler-plugin</artifactId>
221+
<version>3.14.0</version>
222+
<configuration>
223+
<source>17</source>
224+
<target>17</target>
225+
</configuration>
196226
</plugin>
227+
228+
<plugin>
229+
<groupId>org.jenkins-ci.tools</groupId>
230+
<artifactId>maven-hpi-plugin</artifactId>
231+
<version>3.65</version>
232+
<extensions>true</extensions>
233+
</plugin>
234+
197235
<plugin>
198236
<groupId>org.codehaus.mojo</groupId>
199237
<artifactId>cobertura-maven-plugin</artifactId>

0 commit comments

Comments
 (0)