Skip to content

Commit faa94c1

Browse files
committed
Merge branch 'master' into post-SECURITY-359
2 parents 7231c3b + 0b7bf3d commit faa94c1

File tree

349 files changed

+16910
-5583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

349 files changed

+16910
-5583
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @jenkinsci/workflow-cps-plugin-developers

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ updates:
1313
directory: "/"
1414
schedule:
1515
interval: "weekly"
16+
- package-ecosystem: "npm"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"

.github/workflows/cd.yaml

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,8 @@ on:
88
- completed
99

1010
jobs:
11-
validate:
12-
runs-on: ubuntu-latest
13-
outputs:
14-
should_release: ${{ steps.verify-ci-status.outputs.result == 'success' && steps.interesting-categories.outputs.interesting == 'true' }}
15-
steps:
16-
- name: Verify CI status
17-
uses: jenkins-infra/[email protected]
18-
id: verify-ci-status
19-
with:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
output_result: true
22-
23-
- name: Release Drafter
24-
uses: release-drafter/release-drafter@v5
25-
if: steps.verify-ci-status.outputs.result == 'success'
26-
with:
27-
name: next
28-
tag: next
29-
version: next
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
33-
- name: Check interesting categories
34-
uses: jenkins-infra/[email protected]
35-
id: interesting-categories
36-
if: steps.verify-ci-status.outputs.result == 'success'
37-
with:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
40-
release:
41-
runs-on: ubuntu-latest
42-
needs: [validate]
43-
if: needs.validate.outputs.should_release == 'true'
44-
steps:
45-
- name: Check out
46-
uses: actions/checkout@v3
47-
with:
48-
fetch-depth: 0
49-
- name: Set up JDK 8
50-
uses: actions/setup-java@v3
51-
with:
52-
distribution: temurin
53-
java-version: 8
54-
- name: Release
55-
uses: jenkins-infra/[email protected]
56-
with:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
59-
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
60-
11+
maven-cd:
12+
uses: jenkins-infra/github-reusable-workflows/.github/workflows/maven-cd.yml@v1
13+
secrets:
14+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
15+
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}

.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.3</version>
5+
<version>1.4</version>
66
</extension>
77
</extensions>

Jenkinsfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
buildPlugin(useContainerAgent: true, configurations: [
2-
[ platform: "docker", jdk: "8" ],
3-
[ platform: "windows", jdk: "8" ],
2+
[ platform: "windows", jdk: "11" ],
43
[ platform: "linux", jdk: "11" ]
54
])

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
## Introduction
44

5-
A key component of the Pipeline plugin suite, this provides the standard execution engine for Pipeline steps, based on a custom [Groovy](http://www.groovy-lang.org/) interpreter that runs inside the Jenkins controller process.
5+
A key component of the Pipeline plugin suite, this provides the standard execution engine for Pipeline steps, based on a custom [Groovy](https://www.groovy-lang.org/) interpreter that runs inside the Jenkins controller process.
66

77
(In principle other execution engines could be supported, with `FlowDefinition` being the API entry point, but none has been prototyped and it would likely be a very substantial effort to write one.)
88

99
Pipeline Groovy script code such as
1010

1111
```groovy
1212
retry(3) {
13-
for (int i = 0; i < 10; i++) {
14-
branches["branch${i}"] = {
15-
node {
16-
retry(3) {
17-
checkout scm
13+
for (int i = 0; i < 10; i++) {
14+
branches["branch${i}"] = {
15+
node {
16+
retry(3) {
17+
checkout scm
18+
}
19+
sh 'make world'
1820
}
19-
sh 'make world'
2021
}
2122
}
2223
}
@@ -49,7 +50,7 @@ This plugin was previously the "Workflow CPS plugin" or "Workflow Groovy Plugin"
4950

5051
## Technical design
5152

52-
The plugin uses the [Groovy CPS library](https://github.com/cloudbees/groovy-cps/) to implement a [continuation-passing style transformation](https://en.wikipedia.org/wiki/Continuation-passing_style) on the program as it is compiled.
53+
The plugin uses the Groovy CPS library to implement a [continuation-passing style transformation](https://en.wikipedia.org/wiki/Continuation-passing_style) on the program as it is compiled.
5354
The standard Groovy compiler is used to create the AST, but generation of bytecode is intercepted by a `CompilationCustomizer` which replaces most operations with variants that throw a special “error”, `CpsCallableInvocation`.
5455
This is then caught by the engine, which uses information from it (such as arguments about to be passed to a method call) to pass control on to the next continuation.
5556

@@ -72,3 +73,8 @@ The `parallel` step uses “green threads” (also known as coöperative multita
7273
The program may seem to perform tasks concurrently, but only because most steps run asynchronously, while the VM thread is idle, and they may overlap in time.
7374
No Java thread is consumed except during the typically brief intervals when Groovy code is actually being run on the VM thread.
7475
The executor widget only displays an entry for the “flyweight” executor on the built-in node when the VM thread is busy; normally it is hidden.
76+
77+
* [Basics of CPS](doc/cps-basics.md)
78+
* [Continuation, Next, and Env](doc/cps-model.md) and how we interpret Groovy program
79+
* [How interpreted program is represented](doc/block-tree.md)
80+
* [CPS + Sandbox](doc/sandbox.md)

dgm-builder/pom.xml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
7+
<artifactId>workflow-cps-parent</artifactId>
8+
<version>${changelist}</version>
9+
</parent>
10+
11+
<groupId>com.cloudbees</groupId>
12+
<artifactId>groovy-cps-dgm-builder</artifactId>
13+
14+
<name>CpsDefaultGroovyMethods generator</name>
15+
16+
<licenses>
17+
<license>
18+
<name>The Apache Software License, Version 2.0</name>
19+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
20+
<distribution>repo</distribution>
21+
</license>
22+
</licenses>
23+
24+
<properties>
25+
<maven.compiler.release>11</maven.compiler.release>
26+
<maven.compiler.testRelease>11</maven.compiler.testRelease>
27+
<maven.deploy.skip>true</maven.deploy.skip>
28+
</properties>
29+
30+
<build>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-assembly-plugin</artifactId>
35+
<executions>
36+
<execution>
37+
<phase>package</phase>
38+
<goals>
39+
<goal>single</goal>
40+
</goals>
41+
<configuration>
42+
<archive>
43+
<manifest>
44+
<mainClass>com.cloudbees.groovy.cps.tool.Driver</mainClass>
45+
</manifest>
46+
</archive>
47+
<descriptorRefs>
48+
<descriptorRef>jar-with-dependencies</descriptorRef>
49+
</descriptorRefs>
50+
</configuration>
51+
</execution>
52+
</executions>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
57+
<dependencies>
58+
<dependency>
59+
<!-- TODO: Once we are ok limiting workflow-cps (and groovy-cps) to compile _and_ run only on Java 9+, we should delete this dependency and switch to javax.annotation.processing.Generated. -->
60+
<groupId>javax.annotation</groupId>
61+
<artifactId>javax.annotation-api</artifactId>
62+
<version>1.3.2</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.kohsuke.codemodel</groupId>
66+
<artifactId>codemodel</artifactId>
67+
<version>2.7</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.jenkins-ci.main</groupId>
71+
<artifactId>remoting</artifactId>
72+
<version>4.13.3</version>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.codehaus.groovy</groupId>
76+
<artifactId>groovy</artifactId>
77+
<version>${groovy.version}</version>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.codehaus.groovy</groupId>
81+
<artifactId>groovy</artifactId>
82+
<classifier>sources</classifier>
83+
<version>${groovy.version}</version>
84+
</dependency>
85+
</dependencies>
86+
87+
<profiles>
88+
<profile>
89+
<id>skip-installation</id>
90+
<activation>
91+
<property>
92+
<name>set.changelist</name>
93+
<value>true</value>
94+
</property>
95+
</activation>
96+
<properties>
97+
<maven.install.skip>true</maven.install.skip>
98+
</properties>
99+
</profile>
100+
</profiles>
101+
</project>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.cloudbees.groovy.cps.tool;
2+
3+
import com.sun.codemodel.writer.FileCodeWriter;
4+
import groovy.lang.GroovyShell;
5+
import hudson.remoting.Which;
6+
7+
import javax.tools.DiagnosticListener;
8+
import javax.tools.JavaCompiler;
9+
import javax.tools.JavaFileObject;
10+
import javax.tools.StandardJavaFileManager;
11+
import javax.tools.StandardLocation;
12+
import javax.tools.ToolProvider;
13+
import java.io.File;
14+
import java.nio.charset.Charset;
15+
import java.nio.file.Files;
16+
import java.nio.file.Paths;
17+
import java.util.ArrayList;
18+
import java.util.Collections;
19+
import java.util.List;
20+
import java.util.Locale;
21+
22+
import static java.util.Arrays.*;
23+
24+
public class Driver {
25+
public static void main(String[] args) throws Exception {
26+
new Driver().run(new File(args[0]));
27+
}
28+
29+
public void run(File dir) throws Exception {
30+
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
31+
DiagnosticListener<JavaFileObject> errorListener = createErrorListener();
32+
33+
try (StandardJavaFileManager fileManager = javac.getStandardFileManager(errorListener, Locale.getDefault(), Charset.defaultCharset())) {
34+
fileManager.setLocation(StandardLocation.CLASS_PATH,
35+
Collections.singleton(Which.jarFile(GroovyShell.class)));
36+
37+
File groovySrcJar = Which.jarFile(Driver.class.getClassLoader().getResource("groovy/lang/GroovyShell.java"));
38+
39+
// classes to translate
40+
// TODO include other classes mentioned in DefaultGroovyMethods.DGM_LIKE_CLASSES if they have any applicable methods
41+
List<String> fileNames = asList("DefaultGroovyMethods",
42+
"DefaultGroovyStaticMethods",
43+
"StringGroovyMethods");
44+
45+
List<JavaFileObject> src = new ArrayList<>();
46+
for (JavaFileObject jfo : fileManager.list(StandardLocation.CLASS_PATH, "org.codehaus.groovy.runtime", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
47+
for (String name : fileNames) {
48+
if (jfo.toUri().toString().endsWith("/org/codehaus/groovy/runtime/" + name + ".java")) {
49+
src.add(jfo);
50+
break;
51+
}
52+
}
53+
}
54+
55+
// annotation processing appears to cause the source files to be reparsed
56+
// (even though I couldn't find exactly where it's done), which causes
57+
// Tree symbols created by the original JavacTask.parse() call to be thrown away,
58+
// which breaks later processing.
59+
// So for now, don't perform annotation processing
60+
List<String> options = asList("-proc:none");
61+
62+
Translator t = new Translator(javac.getTask(null, fileManager, errorListener, options, null, src));
63+
64+
for (String name : fileNames) {
65+
t.translate(
66+
"org.codehaus.groovy.runtime."+name,
67+
"com.cloudbees.groovy.cps.Cps"+name,
68+
groovySrcJar.getName());
69+
}
70+
71+
72+
Files.createDirectories(dir.toPath());
73+
t.generateTo(new FileCodeWriter(dir));
74+
}
75+
}
76+
77+
private DiagnosticListener<JavaFileObject> createErrorListener() {
78+
return System.out::println;
79+
}
80+
81+
}

0 commit comments

Comments
 (0)