Skip to content

Commit 93d4621

Browse files
committed
Merge remote-tracking branch 'upstream/master' into logging-exMTL
2 parents c438ebd + bef4b5c commit 93d4621

File tree

25 files changed

+495
-1202
lines changed

25 files changed

+495
-1202
lines changed

CHANGELOG.md

Lines changed: 0 additions & 777 deletions
This file was deleted.

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.1.1</version>
53+
<version>3.2.0</version>
5454
<executions>
5555
<execution>
5656
<phase>generate-sources</phase>

lib/src/main/java/com/cloudbees/groovy/cps/impl/NotBlock.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public Next receive(Object o) {
3434
return new ContinuationImpl(e, k).then(b, e, cast);
3535
}
3636

37+
@SuppressFBWarnings(value = "SIC_INNER_SHOULD_BE_STATIC", justification = "Too late to fix compatibly.")
3738
class ContinuationImpl extends ContinuationGroup {
3839
final Continuation k;
3940
final Env e;

plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"less": "^3.12.2",
3232
"less-loader": "^7.0.2",
3333
"mini-css-extract-plugin": "^1.2.1",
34-
"postcss": "^8.2.13",
34+
"postcss": "^8.4.35",
3535
"postcss-less": "^4.0.0",
3636
"postcss-loader": "^4.0.4",
3737
"style-loader": "^2.0.0",

plugin/pom.xml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,11 @@
4949
<dependencies>
5050
<dependency>
5151
<groupId>io.jenkins.tools.bom</groupId>
52-
<artifactId>bom-2.387.x</artifactId>
53-
<version>2378.v3e03930028f2</version>
52+
<artifactId>bom-2.414.x</artifactId>
53+
<version>2746.vb_79a_1d3e7b_c8</version>
5454
<scope>import</scope>
5555
<type>pom</type>
5656
</dependency>
57-
<!-- TODO until in BOM: -->
58-
<dependency>
59-
<groupId>org.jenkins-ci.plugins</groupId>
60-
<artifactId>support-core</artifactId>
61-
<version>1366.v9d076592655d</version>
62-
</dependency>
6357
</dependencies>
6458
</dependencyManagement>
6559
<dependencies>
@@ -110,12 +104,6 @@
110104
</exclusion>
111105
</exclusions>
112106
</dependency>
113-
<dependency>
114-
<groupId>org.jenkins-ci.plugins.workflow</groupId>
115-
<artifactId>workflow-step-api</artifactId>
116-
<classifier>tests</classifier>
117-
<scope>test</scope>
118-
</dependency>
119107
<dependency>
120108
<groupId>org.jenkins-ci.plugins.workflow</groupId>
121109
<artifactId>workflow-support</artifactId>
@@ -259,7 +247,7 @@
259247
<dependency>
260248
<groupId>org.testcontainers</groupId>
261249
<artifactId>testcontainers</artifactId>
262-
<version>1.19.3</version>
250+
<version>1.19.6</version>
263251
<scope>test</scope>
264252
<exclusions>
265253
<!-- Provided by Jenkins core -->

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public class CpsFlowExecution extends FlowExecution implements BlockableResume {
267267
*
268268
* @see #runInCpsVmThread(FutureCallback)
269269
*/
270+
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "TODO clean up")
270271
public transient volatile ListenableFuture<CpsThreadGroup> programPromise;
271272
private transient volatile Collection<ListenableFuture<?>> pickleFutures;
272273

@@ -915,7 +916,19 @@ private void loadProgramFailed(final Throwable problem, SettableFuture<CpsThread
915916
/** Report a fatal error in the VM. */
916917
void croak(Throwable t) {
917918
setResult(Result.FAILURE);
918-
onProgramEnd(new Outcome(null, t));
919+
boolean noStartNodes;
920+
synchronized (this) {
921+
noStartNodes = startNodes == null || startNodes.isEmpty();
922+
}
923+
if (noStartNodes) {
924+
try {
925+
createPlaceholderNodes(t);
926+
} catch (Exception x) {
927+
LOGGER.log(Level.WARNING, "Failed to create placeholder nodes in " + owner, x);
928+
}
929+
} else {
930+
onProgramEnd(new Outcome(null, t));
931+
}
919932
cleanUpHeap();
920933
try {
921934
saveOwner();
@@ -1280,6 +1293,8 @@ public List<Action> loadActions(FlowNode node) throws IOException {
12801293
public void saveActions(FlowNode node, List<Action> actions) throws IOException {
12811294
if (storage == null) {
12821295
throw new IOException("storage not yet loaded");
1296+
} else if (isComplete()) {
1297+
throw new IOException("Cannot save actions for " + node + " for completed execution " + this + ": " + actions);
12831298
}
12841299
storage.saveActions(node, actions);
12851300
}

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/actions/ArgumentsActionImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import hudson.model.Result;
3232
import java.util.Collection;
3333
import jenkins.model.Jenkins;
34-
import org.apache.commons.io.output.NullOutputStream;
3534
import org.jenkinsci.plugins.structs.describable.DescribableModel;
3635
import org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable;
3736
import org.jenkinsci.plugins.workflow.actions.ArgumentsAction;
@@ -41,6 +40,7 @@
4140

4241
import edu.umd.cs.findbugs.annotations.CheckForNull;
4342
import edu.umd.cs.findbugs.annotations.NonNull;
43+
import java.io.OutputStream;
4444
import java.lang.reflect.Type;
4545
import java.net.URL;
4646
import java.util.ArrayList;
@@ -240,6 +240,9 @@ Object sanitizeObjectAndRecordMutation(@CheckForNull Object o, @CheckForNull Env
240240
this.isUnmodifiedBySanitization = true;
241241
return NotStoredReason.UNSERIALIZABLE;
242242
}
243+
} else if (modded instanceof String && ((String) modded).contains("\0")) {
244+
this.isUnmodifiedBySanitization = false;
245+
return "<contains ASCII NUL>";
243246
} else if (modded instanceof String && vars != null && !vars.isEmpty()) {
244247
String replaced = replaceSensitiveVariables((String)modded, vars, sensitiveVariables);
245248
if (!replaced.equals(modded)) {
@@ -282,7 +285,7 @@ Map<String, Object> serializationCheck(@NonNull Map<String, Object> arguments) {
282285
try {
283286
if (val != null && !(val instanceof String) && !(val instanceof Boolean) && !(val instanceof Number) && !(val instanceof NotStoredReason) && !(val instanceof TimeUnit)) {
284287
// We only need to check serialization for nontrivial types
285-
Jenkins.XSTREAM2.toXMLUTF8(entry.getValue(), NullOutputStream.NULL_OUTPUT_STREAM); // Hacky but can't find a better way
288+
Jenkins.XSTREAM2.toXMLUTF8(entry.getValue(), OutputStream.nullOutputStream()); // Hacky but can't find a better way
286289
}
287290
out.put(entry.getKey(), entry.getValue());
288291
} catch (Exception ex) {

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/steps/LoadStep.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package org.jenkinsci.plugins.workflow.cps.steps;
22

33
import hudson.Extension;
4-
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
5-
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
4+
import hudson.FilePath;
5+
import hudson.model.TaskListener;
6+
import java.util.Set;
7+
import org.jenkinsci.plugins.workflow.steps.Step;
8+
import org.jenkinsci.plugins.workflow.steps.StepContext;
9+
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
10+
import org.jenkinsci.plugins.workflow.steps.StepExecution;
611
import org.kohsuke.stapler.DataBoundConstructor;
712

813
/**
914
* Evaluate arbitrary script file.
1015
*
1116
* @author Kohsuke Kawaguchi
1217
*/
13-
public class LoadStep extends AbstractStepImpl {
18+
public class LoadStep extends Step {
1419
/**
1520
* Relative path of the script within the current workspace.
1621
*/
@@ -25,11 +30,13 @@ public String getPath() {
2530
return path;
2631
}
2732

33+
@Override
34+
public StepExecution start(StepContext context) throws Exception {
35+
return new LoadStepExecution(this, context);
36+
}
37+
2838
@Extension
29-
public static class DescriptorImpl extends AbstractStepDescriptorImpl {
30-
public DescriptorImpl() {
31-
super(LoadStepExecution.class);
32-
}
39+
public static class DescriptorImpl extends StepDescriptor {
3340

3441
@Override
3542
public String getFunctionName() {
@@ -40,6 +47,11 @@ public String getFunctionName() {
4047
public String getDisplayName() {
4148
return "Evaluate a Groovy source file into the Pipeline script";
4249
}
50+
51+
@Override
52+
public Set<? extends Class<?>> getRequiredContext() {
53+
return Set.of(FilePath.class, TaskListener.class);
54+
}
4355
}
4456

4557
}

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/steps/LoadStepExecution.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.jenkinsci.plugins.workflow.cps.steps;
22

3-
import com.google.inject.Inject;
43
import groovy.lang.Script;
54
import hudson.FilePath;
65
import hudson.model.TaskListener;
@@ -12,26 +11,27 @@
1211
import org.jenkinsci.plugins.workflow.cps.replay.ReplayAction;
1312
import org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl;
1413
import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback;
15-
import org.jenkinsci.plugins.workflow.steps.StepContextParameter;
14+
import org.jenkinsci.plugins.workflow.steps.StepContext;
1615

1716
/**
1817
* Loads another Groovy script file and executes it.
1918
*
2019
* @author Kohsuke Kawaguchi
2120
*/
2221
public class LoadStepExecution extends AbstractStepExecutionImpl {
23-
@StepContextParameter
24-
private transient FilePath cwd;
2522

26-
@Inject(optional=true)
2723
private transient LoadStep step;
2824

29-
@StepContextParameter
30-
private transient TaskListener listener;
25+
LoadStepExecution(LoadStep step, StepContext context) {
26+
super(context);
27+
this.step = step;
28+
}
3129

3230
@Override
3331
public boolean start() throws Exception {
3432
CpsStepContext cps = (CpsStepContext) getContext();
33+
FilePath cwd = cps.get(FilePath.class);
34+
TaskListener listener = cps.get(TaskListener.class);
3535
CpsThread t = CpsThread.current();
3636

3737
CpsFlowExecution execution = t.getExecution();
@@ -62,6 +62,11 @@ public boolean start() throws Exception {
6262
return false;
6363
}
6464

65+
@Override
66+
public void onResume() {
67+
// do nothing
68+
}
69+
6570
private static final long serialVersionUID = 1L;
6671

6772
}

plugin/src/main/resources/org/jenkinsci/plugins/workflow/cps/Snippetizer/handle-prototype.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function handlePrototype(url, crumb) {
1+
function handlePrototype(url) {
22
buildFormTree(document.forms.config);
33
// TODO JSON.stringify fails in some circumstances: https://gist.github.com/jglick/70ec4b15c1f628fdf2e9 due to Array.prototype.toJSON
44
// TODO simplify when Prototype.js is removed
@@ -7,13 +7,11 @@ function handlePrototype(url, crumb) {
77
return; // just a separator
88
}
99

10-
const headers = new Headers();
11-
headers.append("Content-Type", "application/x-www-form-urlencoded");
12-
headers.append("Jenkins-Crumb", crumb);
13-
1410
fetch(url, {
1511
method: "POST",
16-
headers: headers,
12+
headers: crumb.wrap({
13+
"Content-Type": "application/x-www-form-urlencoded"
14+
}),
1715
body: "json=" + encodeURIComponent(json),
1816

1917
})
@@ -37,9 +35,8 @@ document.addEventListener('DOMContentLoaded', () => {
3735

3836
const generatePipelineScript = document.getElementById("generatePipelineScript");
3937
const url = generatePipelineScript.getAttribute("data-url");
40-
const crumb = generatePipelineScript.getAttribute("data-crumb");
4138
generatePipelineScript.onclick = (_) => {
42-
handlePrototype(url, crumb);
39+
handlePrototype(url);
4340
return false;
4441
};
4542

0 commit comments

Comments
 (0)