diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
new file mode 100644
index 00000000..1e0df49d
--- /dev/null
+++ b/.github/CODEOWNERS
@@ -0,0 +1 @@
+* @jenkinsci/build-failure-analyzer-plugin-developers
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..978c2925
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,12 @@
+# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
+---
+version: 2
+updates:
+ - package-ecosystem: "maven"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/jenkins-security-scan.yml b/.github/workflows/jenkins-security-scan.yml
index d46e12d3..6ba72d8e 100644
--- a/.github/workflows/jenkins-security-scan.yml
+++ b/.github/workflows/jenkins-security-scan.yml
@@ -1,3 +1,6 @@
+# Jenkins Security Scan
+# For more information, see: https://www.jenkins.io/doc/developer/security/scan/
+---
name: Jenkins Security Scan
on:
@@ -17,5 +20,5 @@ jobs:
security-scan:
uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2
with:
- java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate.
- java-version: 11 # What version of Java to set up for the build.
+ java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate.
+ # java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default.
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
index f87134b2..1f8a181b 100644
--- a/.github/workflows/release-drafter.yml
+++ b/.github/workflows/release-drafter.yml
@@ -12,6 +12,6 @@ jobs:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into the default branch
- - uses: release-drafter/release-drafter@v5
+ - uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 62ced6c4..08343646 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,15 @@
target
-bin
+
+# mvn hpi:run
+work
+
+# IntelliJ IDEA project files
*.iml
*.iws
*.ipr
-work
-.DS_Store
.idea
+
+# Eclipse project files
+.settings
.classpath
.project
-.settings
diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
index 5f510417..4e0774d5 100644
--- a/.mvn/extensions.xml
+++ b/.mvn/extensions.xml
@@ -2,6 +2,6 @@
io.jenkins.tools.incrementals
git-changelist-maven-extension
- 1.1
+ 1.8
diff --git a/Jenkinsfile b/Jenkinsfile
index 80d60afb..8b7fd8d8 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,3 +1,4 @@
buildPlugin(useContainerAgent: true, configurations: [
- [ platform: 'linux', jdk: '17' ],
+ [platform: 'linux', jdk: 21],
+ [platform: 'windows', jdk: 17],
])
diff --git a/pom.xml b/pom.xml
index 4d551353..c5eb0744 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,3 +1,4 @@
+
4.0.0
com.sonyericsson.jenkins.plugins.bfa
@@ -10,16 +11,16 @@
org.jenkins-ci.plugins
plugin
- 4.67
+ 5.2
2.5.4
-SNAPSHOT
- 2.475
-
- 2254.vcff7a_d4969e5
- 17
+
+ 2.479
+ ${jenkins.baseline}.1
+ jenkinsci/${project.artifactId}-plugin
3.1.1
false
@@ -285,28 +286,15 @@
io.jenkins.tools.bom
- bom-2.462.x
- 3234.v5ca_5154341ef
+ bom-${jenkins.baseline}.x
+ 3559.vb_5b_81183b_d23
import
pom
-
-
- jakarta.servlet
- jakarta.servlet-api
- 5.0.0
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
org.apache.maven.plugins
maven-checkstyle-plugin
@@ -347,9 +335,9 @@
- scm:git:https://github.com/jenkinsci/build-failure-analyzer-plugin.git
- scm:git:git@github.com:jenkinsci/build-failure-analyzer-plugin.git
- https://github.com/jenkinsci/build-failure-analyzer-plugin
+ scm:git:https://github.com/${gitHubRepo}.git
+ scm:git:git@github.com:${gitHubRepo}.git
+ https://github.com/${gitHubRepo}
${scmTag}
diff --git a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/IndicationAnnotatorFactory.java b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/IndicationAnnotatorFactory.java
index 6e3721ab..0d4f8381 100644
--- a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/IndicationAnnotatorFactory.java
+++ b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/IndicationAnnotatorFactory.java
@@ -31,7 +31,7 @@
import hudson.model.Run;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.Stapler;
-import org.kohsuke.stapler.StaplerRequest;
+import org.kohsuke.stapler.StaplerRequest2;
import java.util.List;
@@ -45,7 +45,7 @@ public class IndicationAnnotatorFactory extends ConsoleAnnotatorFactory {
@Override
public ConsoleAnnotator newInstance(Object context) {
- StaplerRequest currentRequest = Stapler.getCurrentRequest();
+ StaplerRequest2 currentRequest = Stapler.getCurrentRequest2();
if (currentRequest == null) {
//Accessed through some other means than http, so lets assume it is not a human.
return null;
diff --git a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java
index 95dee924..23ab7f8b 100644
--- a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java
+++ b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java
@@ -54,7 +54,7 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
-import org.kohsuke.stapler.StaplerRequest;
+import org.kohsuke.stapler.StaplerRequest2;
import java.io.File;
import java.util.Arrays;
@@ -797,7 +797,7 @@ public KnowledgeBase.KnowledgeBaseDescriptor getKnowledgeBaseDescriptor(String d
@Override
- public boolean configure(StaplerRequest req, JSONObject o) {
+ public boolean configure(StaplerRequest2 req, JSONObject o) {
KnowledgeBase existingKb = knowledgeBase;
req.bindJSON(this, o);
diff --git a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseBuildAction.java b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseBuildAction.java
index 7844bc78..1a7b1b27 100644
--- a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseBuildAction.java
+++ b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseBuildAction.java
@@ -32,8 +32,8 @@
import hudson.model.BuildBadgeAction;
import hudson.model.Run;
import jenkins.model.Jenkins;
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.StaplerResponse;
+import org.kohsuke.stapler.StaplerRequest2;
+import org.kohsuke.stapler.StaplerResponse2;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
@@ -157,7 +157,7 @@ public Object readResolve() {
* @param resp the stapler response.
* @return the correct FoundFailureCause.
*/
- public FoundFailureCause getDynamic(String token, StaplerRequest req, StaplerResponse resp) {
+ public FoundFailureCause getDynamic(String token, StaplerRequest2 req, StaplerResponse2 resp) {
try {
int causeNumber = Integer.parseInt(token) - 1;
if (causeNumber >= 0 && causeNumber < foundFailureCauses.size()) {
@@ -178,7 +178,7 @@ public FoundFailureCause getDynamic(String token, StaplerRequest req, StaplerRes
* @param resp the stapler response
* @throws IOException if so.
*/
- public void doIndex(StaplerRequest req, StaplerResponse resp) throws IOException {
+ public void doIndex(StaplerRequest2 req, StaplerResponse2 resp) throws IOException {
resp.sendRedirect2("../../failure-cause-management");
}
diff --git a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/indication/Indication.java b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/indication/Indication.java
index 4c1d2141..515aa1b3 100644
--- a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/indication/Indication.java
+++ b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/model/indication/Indication.java
@@ -82,7 +82,7 @@ public String getUserProvidedExpression() {
* Override this method to provide more validation.
*
* @return {@link hudson.util.FormValidation#ok()} if everything is well.
- * @see IndicationDescriptor#doHelp(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)
+ * @see IndicationDescriptor#doHelp(org.kohsuke.stapler.StaplerRequest2, org.kohsuke.stapler.StaplerResponse2)
*/
public FormValidation validate() {
return IndicationDescriptor.checkPattern(getUserProvidedExpression());
diff --git a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/sod/ScanOnDemandBaseAction.java b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/sod/ScanOnDemandBaseAction.java
index 468c1202..d189bbbb 100644
--- a/src/main/java/com/sonyericsson/jenkins/plugins/bfa/sod/ScanOnDemandBaseAction.java
+++ b/src/main/java/com/sonyericsson/jenkins/plugins/bfa/sod/ScanOnDemandBaseAction.java
@@ -49,10 +49,10 @@
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.Stapler;
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.StaplerResponse;
+import org.kohsuke.stapler.StaplerRequest2;
+import org.kohsuke.stapler.StaplerResponse2;
-import javax.servlet.ServletException;
+import jakarta.servlet.ServletException;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@@ -176,7 +176,7 @@ public void removeRunActions(MatrixBuild build) {
/**
* Shortcut method to
- * {@link #getDefault()}.{@link ScanMode#doPerformScan(ScanOnDemandBaseAction, StaplerRequest, StaplerResponse)}
+ * {@link #getDefault()}.{@link ScanMode#doPerformScan(ScanOnDemandBaseAction, StaplerRequest2, StaplerResponse2)}
* If the user clicks on scan on the default scanmode page.
*
* @param request the request
@@ -185,7 +185,7 @@ public void removeRunActions(MatrixBuild build) {
* @throws InterruptedException if so
* @throws IOException if so
*/
- public void doPerformScan(StaplerRequest request, StaplerResponse response)
+ public void doPerformScan(StaplerRequest2 request, StaplerResponse2 response)
throws ServletException, InterruptedException, IOException {
getDefault().doPerformScan(this, request, response);
}
@@ -197,7 +197,7 @@ public void doPerformScan(StaplerRequest request, StaplerResponse response)
* @return the default mode.
*/
public ScanMode getDefault() {
- StaplerRequest request = Stapler.getCurrentRequest();
+ StaplerRequest2 request = Stapler.getCurrentRequest2();
if (request != null) {
String selected = (String)request.getSession(true).getAttribute(BFA_SOD_BUILD_TYPE);
if (!isBlank(selected)) {
@@ -314,7 +314,7 @@ public String getFullUrl() {
*/
@SuppressWarnings("unused") //Called by the view
public void setAsDefault() {
- StaplerRequest request = Stapler.getCurrentRequest();
+ StaplerRequest2 request = Stapler.getCurrentRequest2();
if (request == null) {
throw new IllegalStateException("setAsDefault() can only be called in request scope");
}
@@ -325,14 +325,14 @@ public void setAsDefault() {
* Finds the {@link ScanOnDemandBaseAction} in the ancestor path.
*
* Throws {@link IllegalStateException} if we are not in the request scope and
- * {@link Stapler#getCurrentRequest()} returns null.
+ * {@link Stapler#getCurrentRequest2()} returns null.
*
* @return the ancestor action
*
*/
@NonNull
public ScanOnDemandBaseAction getParent() {
- StaplerRequest request = Stapler.getCurrentRequest();
+ StaplerRequest2 request = Stapler.getCurrentRequest2();
if (request == null) {
throw new IllegalStateException("getParent can only be called from request scope.");
}
@@ -352,15 +352,15 @@ public ScanOnDemandBaseAction getParent() {
* Submit method for running build scan.
*
* @param action the action we have as an ancestor
- * @param request StaplerRequest
- * @param response StaplerResponse
+ * @param request StaplerRequest2
+ * @param response StaplerResponse2
* @throws ServletException if something unfortunate happens.
* @throws IOException if something unfortunate happens.
* @throws InterruptedException if something unfortunate happens.
*/
@SuppressWarnings("unused") //Called by the view
public void doPerformScan(@AncestorInPath ScanOnDemandBaseAction action,
- StaplerRequest request, StaplerResponse response)
+ StaplerRequest2 request, StaplerResponse2 response)
throws ServletException, IOException, InterruptedException {
action.checkPermission();
Iterator runIterator = getRuns(action.getProject());
diff --git a/src/test/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseProjectActionHudsonTest.java b/src/test/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseProjectActionHudsonTest.java
index 3f5b4f02..a71dff5e 100644
--- a/src/test/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseProjectActionHudsonTest.java
+++ b/src/test/java/com/sonyericsson/jenkins/plugins/bfa/model/FailureCauseProjectActionHudsonTest.java
@@ -24,13 +24,16 @@
package com.sonyericsson.jenkins.plugins.bfa.model;
import hudson.Functions;
+import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
+import hudson.model.Result;
+import hudson.tasks.BatchFile;
+import hudson.tasks.CommandInterpreter;
import hudson.tasks.Shell;
import org.junit.Test;
import org.jvnet.hudson.test.HudsonTestCase;
-import static org.junit.Assume.assumeFalse;
/**
* Test Failure Cause project action.
*/
@@ -43,16 +46,22 @@ public class FailureCauseProjectActionHudsonTest extends HudsonTestCase {
*/
@Test
public void testShowLastFailureOnProjectPage() throws Exception {
- assumeFalse(Functions.isWindows());
FreeStyleProject project = createFreeStyleProject();
- project.getBuildersList().add(new Shell("test $BUILD_NUMBER -eq 2"));
- project.scheduleBuild2(0).get();
+ CommandInterpreter commandInterpreter;
+ if (Functions.isWindows()) {
+ commandInterpreter = new BatchFile("@if %BUILD_NUMBER% == 1 exit /b 1");
+ } else {
+ commandInterpreter = new Shell("test $BUILD_NUMBER -ne 1");
+ }
+ project.getBuildersList().add(commandInterpreter);
+ FreeStyleBuild build = project.scheduleBuild2(0).get();
+ assertBuildStatus(Result.FAILURE, build);
FailureCauseProjectAction action = project.getAction(FailureCauseProjectAction.class);
assertNotNull(action.getAction());
- assertEquals(project.getLastBuild().getAction(FailureCauseBuildAction.class), action.getAction());
+ assertEquals(build.getAction(FailureCauseBuildAction.class), action.getAction());
- project.scheduleBuild2(0).get();
+ buildAndAssertSuccess(project);
assertNull(project.getAction(FailureCauseProjectAction.class).getAction());
}
}