Skip to content

Commit 92b74f1

Browse files
authored
Merge branch 'master' into logging-exMTL
2 parents 1692243 + e65bfa6 commit 92b74f1

26 files changed

+1080
-737
lines changed

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<extension>
33
<groupId>io.jenkins.tools.incrementals</groupId>
44
<artifactId>git-changelist-maven-extension</artifactId>
5-
<version>1.8</version>
5+
<version>1.10</version>
66
</extension>
77
</extensions>

lib/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<plugin>
5151
<groupId>org.codehaus.mojo</groupId>
5252
<artifactId>exec-maven-plugin</artifactId>
53-
<version>3.5.0</version>
53+
<version>3.5.1</version>
5454
<executions>
5555
<execution>
5656
<phase>generate-sources</phase>

plugin/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@
2020
},
2121
"readme": "../README.md",
2222
"devDependencies": {
23-
"@babel/cli": "^7.27.0",
24-
"@babel/core": "^7.26.10",
25-
"@babel/preset-env": "^7.26.9",
23+
"@babel/cli": "^7.27.2",
24+
"@babel/core": "^7.27.4",
25+
"@babel/preset-env": "^7.27.2",
2626
"@delucis/if-env": "^1.1.2",
2727
"@eslint/eslintrc": "^3.3.1",
28-
"@eslint/js": "^9.24.0",
28+
"@eslint/js": "^9.29.0",
2929
"autoprefixer": "^10.4.21",
3030
"babel-loader": "^10.0.0",
3131
"clean-webpack-plugin": "^4.0.0",
3232
"css-loader": "^7.1.2",
33-
"eslint": "^9.24.0",
33+
"eslint": "^9.29.0",
3434
"eslint-formatter-checkstyle": "^8.40.0",
3535
"eslint-plugin-only-warn": "^1.1.0",
36-
"globals": "^16.0.0",
36+
"globals": "^16.2.0",
3737
"less": "^4.3.0",
38-
"less-loader": "^12.2.0",
38+
"less-loader": "^12.3.0",
3939
"mini-css-extract-plugin": "^2.9.2",
40-
"postcss": "^8.4.35",
40+
"postcss": "^8.5.6",
4141
"postcss-less": "^6.0.0",
4242
"postcss-loader": "^8.1.1",
4343
"style-loader": "^4.0.0",
44-
"webpack": "^5.99.5",
44+
"webpack": "^5.99.9",
4545
"webpack-cli": "^6.0.1",
4646
"webpack-fix-style-only-entries": "^0.6.1",
4747
"webpack-merge": "^6.0.1"
4848
},
4949
"dependencies": {
50-
"ace-builds": "^1.40.0",
50+
"ace-builds": "^1.43.2",
5151
"jquery": "^3.7.1",
5252
"jquery-ui": "^1.14.1"
5353
},

plugin/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@
4747
<!-- Opt in to Jenkins handling eslint results -->
4848
<maven.test.failure.ignore>false</maven.test.failure.ignore>
4949
<frontend.testFailureIgnore>${maven.test.failure.ignore}</frontend.testFailureIgnore>
50+
<useBeta>true</useBeta> <!-- FailureHandler -->
5051
</properties>
5152
<dependencyManagement>
5253
<dependencies>
5354
<dependency>
5455
<groupId>io.jenkins.tools.bom</groupId>
5556
<artifactId>bom-${jenkins.baseline}.x</artifactId>
56-
<version>4488.v7fe26526366e</version>
57+
<version>5043.v855ff4819a_0f</version>
5758
<scope>import</scope>
5859
<type>pom</type>
5960
</dependency>
@@ -229,7 +230,7 @@
229230
<dependency>
230231
<groupId>org.testcontainers</groupId>
231232
<artifactId>testcontainers</artifactId>
232-
<version>1.20.6</version>
233+
<version>1.21.3</version>
233234
<scope>test</scope>
234235
<exclusions>
235236
<!-- Provided by Jenkins core -->
@@ -255,6 +256,11 @@
255256
<artifactId>test-harness</artifactId>
256257
<scope>test</scope>
257258
</dependency>
259+
<dependency>
260+
<groupId>io.jenkins.plugins</groupId>
261+
<artifactId>commons-lang3-api</artifactId>
262+
<scope>test</scope>
263+
</dependency>
258264
</dependencies>
259265
<build>
260266
<resources>

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsBodyExecution.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.jenkinsci.plugins.workflow.cps.persistence.PersistenceContext;
1919
import org.jenkinsci.plugins.workflow.steps.BodyExecution;
2020
import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback;
21+
import org.jenkinsci.plugins.workflow.steps.FailureHandler;
2122
import org.jenkinsci.plugins.workflow.steps.StepContext;
2223
import org.jenkinsci.plugins.workflow.steps.StepExecution;
2324

@@ -344,14 +345,16 @@ public Next receive(Object o) {
344345
StepStartNode ssn = addBodyStartFlowNode(h);
345346
h.setNewHead(ssn);
346347
}
347-
348348
StepEndNode en = addBodyEndFlowNode();
349349
Throwable t = (Throwable)o;
350+
351+
var sc = new CpsBodySubContext(context, en);
352+
t = handleError(sc, t);
353+
350354
en.addAction(new ErrorAction(t));
351355
CpsFlowExecution.maybeAutoPersistNode(en);
352356

353357
setOutcome(new Outcome(null,t));
354-
StepContext sc = new CpsBodySubContext(context, en);
355358
for (BodyExecutionCallback c : callbacks) {
356359
try {
357360
c.onFailure(sc, t);
@@ -366,6 +369,27 @@ public Next receive(Object o) {
366369
return Next.terminate(null);
367370
}
368371

372+
private Throwable handleError(CpsBodySubContext sc, Throwable t) {
373+
CpsThread localThread;
374+
synchronized (CpsBodyExecution.this) {
375+
localThread = thread;
376+
}
377+
try {
378+
var contextVars = localThread.getContextVariables();
379+
// CpsFlowExecution.start sets the context variables for the initial CpsThread to null, so context
380+
// variables for all subsequent threads remain null until a block step adds a variable to its body.
381+
if (contextVars != null) {
382+
var handler = contextVars.get(FailureHandler.class, localThread::getExecution, sc::getNode);
383+
if (handler != null) {
384+
return handler.handle(sc, t);
385+
}
386+
}
387+
} catch (Throwable t2) {
388+
t.addSuppressed(t2);
389+
}
390+
return t;
391+
}
392+
369393
private static final long serialVersionUID = 1L;
370394
}
371395

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsBodySubContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class CpsBodySubContext extends DefaultStepContext {
3535

3636
@NonNull
3737
@Override
38-
protected FlowNode getNode() throws IOException {
38+
protected FlowNode getNode() {
3939
return node;
4040
}
4141

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import hudson.util.StreamTaskListener;
4242
import jenkins.model.Jenkins;
4343
import net.sf.json.JSONObject;
44-
import org.apache.commons.lang.StringUtils;
4544
import org.jenkinsci.plugins.workflow.cps.persistence.PersistIn;
4645
import org.jenkinsci.plugins.workflow.flow.DurabilityHintProvider;
4746
import org.jenkinsci.plugins.workflow.flow.FlowDefinition;
@@ -56,6 +55,7 @@
5655

5756
import java.io.IOException;
5857
import java.util.List;
58+
import java.util.Objects;
5959

6060
import net.sf.json.JSON;
6161
import net.sf.json.JSONArray;
@@ -170,7 +170,7 @@ public FlowDefinition newInstance(@NonNull StaplerRequest req, @NonNull JSONObje
170170
private FlowDefinition newInstanceImpl(CpsFlowDefinition cpsFlowDefinition, @NonNull StaplerRequest2 req, @NonNull JSONObject formData) {
171171
if (!cpsFlowDefinition.sandbox && formData.get("oldScript") != null) {
172172
String oldScript = formData.getString("oldScript");
173-
boolean approveIfAdmin = !StringUtils.equals(oldScript, cpsFlowDefinition.script);
173+
boolean approveIfAdmin = !Objects.equals(oldScript, cpsFlowDefinition.script);
174174
if (approveIfAdmin) {
175175
ScriptApproval.get().configuring(cpsFlowDefinition.script, GroovyLanguage.get(),
176176
ApprovalContext.create().withCurrentUser().withItemAsKey(req.findAncestorObject(Item.class)), true);
@@ -188,7 +188,7 @@ public String getDisplayName() {
188188
public FormValidation doCheckScript(@QueryParameter String value, @QueryParameter String oldScript,
189189
@QueryParameter boolean sandbox) {
190190
return sandbox ? FormValidation.ok() :
191-
ScriptApproval.get().checking(value, GroovyLanguage.get(), !StringUtils.equals(oldScript, value));
191+
ScriptApproval.get().checking(value, GroovyLanguage.get(), !Objects.equals(oldScript, value));
192192
}
193193

194194
@RequirePOST

0 commit comments

Comments
 (0)