Skip to content

Commit

Permalink
Merge branch 'master' into JENKINS-70695
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinter69 authored Oct 28, 2023
2 parents 33d80ff + a3a6988 commit 4a01731
Show file tree
Hide file tree
Showing 51 changed files with 1,362 additions and 689 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ updates:
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/"
directory: "/plugin"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.6</version>
<version>1.7</version>
</extension>
</extensions>
14 changes: 11 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
buildPlugin(useContainerAgent: true, configurations: [
[ platform: "windows", jdk: "11" ],
[ platform: "linux", jdk: "17" ]
/*
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
buildPlugin(
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
configurations: [
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17],
])
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ The executor widget only displays an entry for the “flyweight” executor on t
* [Continuation, Next, and Env](doc/cps-model.md) and how we interpret Groovy program
* [How interpreted program is represented](doc/block-tree.md)
* [CPS + Sandbox](doc/sandbox.md)

## Development

When developing the editor, edit `plugin/package.json` to set `mvnbuild` to `yarn dev` instead of `yarn prod`.
This will allow you to do in situ debugging of JavaScript in your browser.
2 changes: 1 addition & 1 deletion doc/classloader.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ which is not trusted.
Scripts loaded in TCL, OTOH, does not live in the security sandbox. This
classloader is meant to be used to load Groovy code packaged inside
plugins and global libraries. Write access to these sources should be
restricted to `RUN_SCRIPTS` permission.
restricted to `ADMINISTER` permission.

## Persisting code & surviving restarts
When a Groovy script is loaded via one of `GroovyShell.parse*()` and
Expand Down
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</build>

<properties>
<groovy-sandbox.version>1.32</groovy-sandbox.version>
<groovy-sandbox.version>1.33</groovy-sandbox.version>
<no-test-jar>false</no-test-jar>
</properties>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ public void exceptionFromNonCpsCodeShouldBeCaughtByCatchBlockInCpsCode() throws
"}\n");
assertThat(message, anyOf(
equalTo("String index out of range: -2"), // Before Java 14
equalTo("begin 5, end 3, length 3"))); // Later versions
equalTo("begin 5, end 3, length 3"), // Before Java 18
equalTo("Range [5, 3) out of bounds for length 3"))); // Later versions
}

/**
Expand Down
26 changes: 3 additions & 23 deletions plugin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,16 @@ module.exports = {
root: true,
env: {
browser: true,
es6: true
es2022: true
},
// Uses eslint default ruleset
extends: "eslint:recommended",
plugins: [
// Keeps the default level to warn to avoid breaking the current
// CI build environment
"only-warn"
],
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2022,
sourceType: "module"
},
rules: {
},
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",

'__dirname': false,

// Allow jest globals used in tests
jest: false,
expect: false,
it: false,
describe: false,
beforeEach: false,
afterEach: false,
beforeAll: false,
afterAll: false,
curly: "error",
}
};

23 changes: 12 additions & 11 deletions plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "workflow-ui",
"version": "1.0.0",
"description": "Jenkins Pipeline UI",
"private": true,
"author": "Tom Fennelly <tom.fennelly@gmail.com> (https://github.com/tfennelly)",
"license": "MIT",
"scripts": {
"dev": "webpack --config webpack.config.js",
"prod": "webpack --config webpack.config.js --mode=production",
"start": "yarn dev -- --watch",
"dev": "webpack --config webpack.dev.js",
"prod": "webpack --config webpack.prod.js",
"start": "yarn dev --watch",
"lint:js": "eslint src/main/js --ext js",
"mvnbuild": "yarn prod",
"mvntest": "yarn lint:js"
Expand All @@ -25,27 +26,27 @@
"babel-loader": "^9.0.1",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^5.0.0",
"eslint": "^7.12.1",
"eslint-plugin-only-warn": "^1.0.3",
"eslint": "^8.41.0",
"eslint-plugin-only-warn": "^1.1.0",
"less": "^3.12.2",
"less-loader": "^7.0.2",
"mini-css-extract-plugin": "^1.2.1",
"postcss": "^8.2.13",
"postcss-less": "^4.0.0",
"postcss-loader": "^4.0.4",
"style-loader": "^2.0.0",
"webpack": "5.74.0",
"webpack-cli": "^4.10.0",
"webpack-fix-style-only-entries": "^0.6.1"
"webpack": "^5.76.3",
"webpack-cli": "^5.0.1",
"webpack-fix-style-only-entries": "^0.6.1",
"webpack-merge": "^5.8.0"
},
"dependencies": {
"ace-builds": "^1.15.0",
"jquery": "^3.6.1",
"jquery-ui": "^1.13.2",
"raf": "^3.4.1"
"jquery-ui": "^1.13.2"
},
"browserslist": [
"defaults",
"IE 11"
"not IE 11"
]
}
20 changes: 4 additions & 16 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@
</licenses>
<properties>
<no-test-jar>false</no-test-jar>
<node.version>18.13.0</node.version>
<npm.version>8.19.3</npm.version>
<node.version>18.15.0</node.version>
<yarn.version>1.22.19</yarn.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.361.x</artifactId>
<version>1883.vcb_768a_7c3610</version>
<artifactId>bom-2.387.x</artifactId>
<version>2378.v3e03930028f2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down Expand Up @@ -184,17 +183,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>theme-manager</artifactId>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>io.jenkins.blueocean</groupId>
<artifactId>blueocean-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
Expand Down Expand Up @@ -265,7 +253,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.18.0</version>
<version>1.19.0</version>
<scope>test</scope>
<exclusions>
<!-- Provided by Jenkins core -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.cloudbees.groovy.cps.impl.CpsCallableInvocation;
import com.cloudbees.groovy.cps.impl.FunctionCallEnv;
import com.cloudbees.groovy.cps.impl.TryBlockEnv;
import com.cloudbees.groovy.cps.sandbox.SandboxInvoker;
import com.google.common.util.concurrent.FutureCallback;
import hudson.model.Action;
import hudson.util.Iterators;
Expand Down Expand Up @@ -173,8 +172,7 @@ private Continuable createContinuable(CpsThread currentThread, CpsCallableInvoca
// TODO: we need to capture the surrounding calling context to capture variables, and switch to ClosureCallEnv

FunctionCallEnv caller = new FunctionCallEnv(null, onSuccess, null, null);
if (currentThread.getExecution().isSandbox())
caller.setInvoker(new SandboxInvoker());
caller.setInvoker(currentThread.getExecution().createInvoker());

// catch an exception thrown from body and treat that as a failure
TryBlockEnv env = new TryBlockEnv(caller, null);
Expand Down Expand Up @@ -352,7 +350,12 @@ public Next receive(Object o) {
setOutcome(new Outcome(null,t));
StepContext sc = new CpsBodySubContext(context, en);
for (BodyExecutionCallback c : callbacks) {
c.onFailure(sc, t);
try {
c.onFailure(sc, t);
} catch (Exception e) {
t.addSuppressed(e);
sc.onFailure(t);
}
}
return Next.terminate(null);
}
Expand All @@ -368,7 +371,11 @@ public Next receive(Object o) {
setOutcome(new Outcome(o,null));
StepContext sc = new CpsBodySubContext(context, en);
for (BodyExecutionCallback c : callbacks) {
c.onSuccess(sc, o);
try {
c.onSuccess(sc, o);
} catch (Exception e) {
sc.onFailure(e);
}
}
return Next.terminate(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,16 @@
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.workflow.cps.persistence.PersistIn;
import org.jenkinsci.plugins.workflow.cps.replay.ReplayAction;
import org.jenkinsci.plugins.workflow.cps.view.ThemeUtil;
import org.jenkinsci.plugins.workflow.flow.DurabilityHintProvider;
import org.jenkinsci.plugins.workflow.flow.FlowDefinition;
import org.jenkinsci.plugins.workflow.flow.FlowDefinitionDescriptor;
import org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.flow.GlobalDefaultFlowDurabilityLevel;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import net.sf.json.JSON;
Expand Down Expand Up @@ -184,10 +179,4 @@ public JSON doCheckScriptCompile(@AncestorInPath Item job, @QueryParameter Strin
}

}

/** @see ReplayAction#getTheme */
@Restricted(DoNotUse.class)
/* accessible to Jelly */ public String getTheme() {
return ThemeUtil.getTheme();
}
}
Loading

0 comments on commit 4a01731

Please sign in to comment.