Skip to content

Commit c438ebd

Browse files
authored
Merge branch 'master' into logging-exMTL
2 parents 390427a + 3b5707f commit c438ebd

File tree

9 files changed

+81
-33
lines changed

9 files changed

+81
-33
lines changed

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

plugin/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
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>
5763
</dependencies>
5864
</dependencyManagement>
5965
<dependencies>
@@ -253,7 +259,7 @@
253259
<dependency>
254260
<groupId>org.testcontainers</groupId>
255261
<artifactId>testcontainers</artifactId>
256-
<version>1.19.0</version>
262+
<version>1.19.3</version>
257263
<scope>test</scope>
258264
<exclusions>
259265
<!-- Provided by Jenkins core -->

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,10 @@ public void autopersist(@NonNull FlowNode n) throws IOException {
20242024
return "Timing data about recently completed Pipeline builds";
20252025
}
20262026

2027+
@Override public ComponentCategory getCategory() {
2028+
return ComponentCategory.BUILDS;
2029+
}
2030+
20272031
@Override public void addContents(Container container) {
20282032
container.add(new Content("nodes/master/pipeline-timings.txt") {
20292033
@Override public void writeTo(OutputStream outputStream) throws IOException {
@@ -2071,6 +2075,10 @@ public void autopersist(@NonNull FlowNode n) throws IOException {
20712075
return "List of internal API calls made by Pipeline builds (typically from trusted libraries)";
20722076
}
20732077

2078+
@Override public ComponentCategory getCategory() {
2079+
return ComponentCategory.BUILDS;
2080+
}
2081+
20742082
@Override public void addContents(Container container) {
20752083
container.add(new Content("nodes/master/pipeline-internal-calls.txt") {
20762084
@Override public void writeTo(OutputStream outputStream) throws IOException {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.io.IOException;
4747
import java.io.InterruptedIOException;
4848
import java.util.Collection;
49+
import java.util.Collections;
4950
import java.util.List;
5051
import jenkins.model.Jenkins;
5152
import jenkins.scm.api.SCMFileSystem;
@@ -85,6 +86,11 @@ public SCM getScm() {
8586
return scm;
8687
}
8788

89+
@Override
90+
public Collection<? extends SCM> getSCMs() {
91+
return Collections.singletonList(scm);
92+
}
93+
8894
public String getScriptPath() {
8995
return scriptPath;
9096
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ public CpsThreadDump getThreadDump() {
102102
return "Thread dumps of running Pipeline builds";
103103
}
104104

105+
@Override public ComponentCategory getCategory() {
106+
return ComponentCategory.BUILDS;
107+
}
108+
105109
@Override public void addContents(Container container) {
106110
container.add(new Content("nodes/master/pipeline-thread-dump.txt") {
107111
@Override public void writeTo(OutputStream outputStream) throws IOException {

plugin/src/main/js/workflow-editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ $(function() {
5454
setTheme(editor);
5555

5656
if (window.isSystemRespectingTheme) {
57-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
57+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
5858
setTheme(editor)
5959
});
6060
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
function handlePrototype(url, crumb) {
2+
buildFormTree(document.forms.config);
3+
// TODO JSON.stringify fails in some circumstances: https://gist.github.com/jglick/70ec4b15c1f628fdf2e9 due to Array.prototype.toJSON
4+
// TODO simplify when Prototype.js is removed
5+
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);
6+
if (!json) {
7+
return; // just a separator
8+
}
9+
10+
const headers = new Headers();
11+
headers.append("Content-Type", "application/x-www-form-urlencoded");
12+
headers.append("Jenkins-Crumb", crumb);
13+
14+
fetch(url, {
15+
method: "POST",
16+
headers: headers,
17+
body: "json=" + encodeURIComponent(json),
18+
19+
})
20+
.then(response => {
21+
if (response.ok) {
22+
response.text().then((responseText) => {
23+
document.getElementById('prototypeText').value = responseText;
24+
copybutton = document.querySelector('.jenkins-copy-button');
25+
copybutton.setAttribute("text", responseText);
26+
copybutton.classList.remove('jenkins-hidden');
27+
});
28+
}
29+
})
30+
.catch(error => {
31+
console.error('Fetch error:', error);
32+
});
33+
}
34+
35+
36+
document.addEventListener('DOMContentLoaded', () => {
37+
38+
const generatePipelineScript = document.getElementById("generatePipelineScript");
39+
const url = generatePipelineScript.getAttribute("data-url");
40+
const crumb = generatePipelineScript.getAttribute("data-crumb");
41+
generatePipelineScript.onclick = (_) => {
42+
handlePrototype(url, crumb);
43+
return false;
44+
};
45+
46+
});

plugin/src/main/resources/org/jenkinsci/plugins/workflow/cps/Snippetizer/index.jelly

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,14 @@ THE SOFTWARE.
6767
<f:dropdownListBlock title="${%— Advanced/Deprecated —}"/>
6868
<local:listSteps quasiDescriptors="${it.getQuasiDescriptors(true)}"/>
6969
</f:dropdownList>
70-
<j:set var="id" value="${h.generateId()}"/>
7170
<f:block>
72-
<input type="button" value="${%Generate Pipeline Script}" onclick="handlePrototype_${id}(); return false" class="submit-button primary"/>
73-
<f:textarea id="prototypeText_${id}" readonly="true" style="margin-top: 10px" />
74-
<script>
75-
function handlePrototype_${id}() {
76-
buildFormTree(document.forms.config);
77-
// TODO JSON.stringify fails in some circumstances: https://gist.github.com/jglick/70ec4b15c1f628fdf2e9 due to Array.prototype.toJSON
78-
// TODO simplify when Prototype.js is removed
79-
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);
80-
if (!json) {
81-
return; // just a separator
82-
}
83-
fetch('${rootURL}/${it.GENERATE_URL}', {
84-
method: 'post',
85-
headers: crumb.wrap({
86-
"Content-Type": "application/x-www-form-urlencoded",
87-
}),
88-
body: new URLSearchParams({
89-
json: json,
90-
}),
91-
}).then((rsp) => {
92-
if (rsp.ok) {
93-
rsp.text().then((responseText) => {
94-
document.getElementById('prototypeText_${id}').value = responseText;
95-
});
96-
}
97-
});
98-
}
99-
</script>
71+
<input type="button" id="generatePipelineScript" value="${%Generate Pipeline Script}"
72+
class="submit-button primary"
73+
data-url="${rootURL}/${it.GENERATE_URL}"
74+
data-crumb="${h.getCrumb(request)}"/>
75+
<f:textarea id="prototypeText" readonly="true" style="margin-top: 10px"/>
76+
<l:copyButton text="" clazz="jenkins-hidden jenkins-!-margin-top-1"/>
77+
<st:adjunct includes="org.jenkinsci.plugins.workflow.cps.Snippetizer.handle-prototype"/>
10078
</f:block>
10179
<f:section title="${%Global Variables}"/>
10280
<f:block>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>4.74</version>
7+
<version>4.75</version>
88
<relativePath/>
99
</parent>
1010
<groupId>org.jenkins-ci.plugins.workflow</groupId>

0 commit comments

Comments
 (0)