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 committed Dec 8, 2023
2 parents 4a01731 + 9d3888c commit e47101f
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
Expand Down
8 changes: 7 additions & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- TODO until in BOM: -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>support-core</artifactId>
<version>1366.v9d076592655d</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -253,7 +259,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.19.0</version>
<version>1.19.3</version>
<scope>test</scope>
<exclusions>
<!-- Provided by Jenkins core -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,10 @@ public void autopersist(@NonNull FlowNode n) throws IOException {
return "Timing data about recently completed Pipeline builds";
}

@Override public ComponentCategory getCategory() {
return ComponentCategory.BUILDS;
}

@Override public void addContents(Container container) {
container.add(new Content("nodes/master/pipeline-timings.txt") {
@Override public void writeTo(OutputStream outputStream) throws IOException {
Expand Down Expand Up @@ -2067,6 +2071,10 @@ public void autopersist(@NonNull FlowNode n) throws IOException {
return "List of internal API calls made by Pipeline builds (typically from trusted libraries)";
}

@Override public ComponentCategory getCategory() {
return ComponentCategory.BUILDS;
}

@Override public void addContents(Container container) {
container.add(new Content("nodes/master/pipeline-internal-calls.txt") {
@Override public void writeTo(OutputStream outputStream) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import jenkins.model.Jenkins;
import jenkins.scm.api.SCMFileSystem;
Expand Down Expand Up @@ -85,6 +86,11 @@ public SCM getScm() {
return scm;
}

@Override
public Collection<? extends SCM> getSCMs() {
return Collections.singletonList(scm);
}

public String getScriptPath() {
return scriptPath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public CpsThreadDump getThreadDump() {
return "Thread dumps of running Pipeline builds";
}

@Override public ComponentCategory getCategory() {
return ComponentCategory.BUILDS;
}

@Override public void addContents(Container container) {
container.add(new Content("nodes/master/pipeline-thread-dump.txt") {
@Override public void writeTo(OutputStream outputStream) throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/js/workflow-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $(function() {
setTheme(editor);

if (window.isSystemRespectingTheme) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
setTheme(editor)
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function handlePrototype(url, crumb) {
buildFormTree(document.forms.config);
// TODO JSON.stringify fails in some circumstances: https://gist.github.com/jglick/70ec4b15c1f628fdf2e9 due to Array.prototype.toJSON
// TODO simplify when Prototype.js is removed
const json = Object.toJSON ? Object.toJSON(JSON.parse(document.forms.config.elements.json.value).prototype) : JSON.stringify(JSON.parse(document.forms.config.elements.json.value).prototype);
if (!json) {
return; // just a separator
}

const headers = new Headers();
headers.append("Content-Type", "application/x-www-form-urlencoded");
headers.append("Jenkins-Crumb", crumb);

fetch(url, {
method: "POST",
headers: headers,
body: "json=" + encodeURIComponent(json),

})
.then(response => {
if (response.ok) {
response.text().then((responseText) => {
document.getElementById('prototypeText').value = responseText;
copybutton = document.querySelector('.jenkins-copy-button');
copybutton.setAttribute("text", responseText);
copybutton.classList.remove('jenkins-hidden');
});
}
})
.catch(error => {
console.error('Fetch error:', error);
});
}


document.addEventListener('DOMContentLoaded', () => {

const generatePipelineScript = document.getElementById("generatePipelineScript");
const url = generatePipelineScript.getAttribute("data-url");
const crumb = generatePipelineScript.getAttribute("data-crumb");
generatePipelineScript.onclick = (_) => {
handlePrototype(url, crumb);
return false;
};

});
Original file line number Diff line number Diff line change
Expand Up @@ -67,40 +67,14 @@ THE SOFTWARE.
<f:dropdownListBlock title="${%— Advanced/Deprecated —}"/>
<local:listSteps quasiDescriptors="${it.getQuasiDescriptors(true)}"/>
</f:dropdownList>
<j:set var="id" value="${h.generateId()}"/>
<f:block>
<input type="button" value="${%Generate Pipeline Script}" onclick="handlePrototype_${id}(); return false" class="submit-button primary"/>
<f:textarea id="prototypeText_${id}" readonly="true" style="margin-top: 10px; margin-bottom: 5px" />
<l:copyButton text="" clazz="jenkins-hidden"/>
<script>
function handlePrototype_${id}() {
buildFormTree(document.forms.config);
// TODO JSON.stringify fails in some circumstances: https://gist.github.com/jglick/70ec4b15c1f628fdf2e9 due to Array.prototype.toJSON
// TODO simplify when Prototype.js is removed
var json = Object.toJSON ? Object.toJSON(JSON.parse(document.forms.config.elements.json.value).prototype) : JSON.stringify(JSON.parse(document.forms.config.elements.json.value).prototype);
if (!json) {
return; // just a separator
}
fetch('${rootURL}/${it.GENERATE_URL}', {
method: 'post',
headers: crumb.wrap({
"Content-Type": "application/x-www-form-urlencoded",
}),
body: new URLSearchParams({
json: json,
}),
}).then((rsp) => {
if (rsp.ok) {
rsp.text().then((responseText) => {
document.getElementById('prototypeText_${id}').value = responseText;
copybutton = document.querySelector('.jenkins-copy-button');
copybutton.setAttribute("text", r.responseText);
copybutton.classList.remove('jenkins-hidden');
});
}
});
}
</script>
<input type="button" id="generatePipelineScript" value="${%Generate Pipeline Script}"
class="submit-button primary"
data-url="${rootURL}/${it.GENERATE_URL}"
data-crumb="${h.getCrumb(request)}"/>
<f:textarea id="prototypeText" readonly="true" style="margin-top: 10px"/>
<l:copyButton text="" clazz="jenkins-hidden jenkins-!-margin-top-1"/>
<st:adjunct includes="org.jenkinsci.plugins.workflow.cps.Snippetizer.handle-prototype"/>
</f:block>
<f:section title="${%Global Variables}"/>
<f:block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,26 @@ public boolean isAllowed(String groovyResourceUrl) {
}
}

@Test public void evaluateAfterRestart() throws Throwable {
sessions.then(r -> {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"def x = evaluate('class X {X() {}; def m1() {/OK/}}; new X()')\n" +
"def y = evaluate('class Y {X x; def m2() {/really ${x.m1()}/}}; new Y()')\n" +
"semaphore('wait')\n" +
"y.x = x\n" +
"echo(/received ${y.m2()}/)\n", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("wait/1", b);
});
sessions.then(r -> {
WorkflowJob p = r.jenkins.getItemByFullName("p", WorkflowJob.class);
WorkflowRun b = p.getLastBuild();
SemaphoreStep.success("wait/1", null);
r.assertLogContains("received really OK", r.assertBuildStatus(Result.SUCCESS, r.waitForCompletion(b)));
});
}

@Issue({ "JENKINS-45327", "JENKINS-68849" })
@Test public void envActionImplPickle() throws Throwable {
sessions.then(r -> {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.74</version>
<version>4.75</version>
<relativePath/>
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down

0 comments on commit e47101f

Please sign in to comment.