Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependencies>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-lang3-api</artifactId>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-text-api</artifactId>
</dependency>
Comment on lines +60 to +67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer #176

<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import jenkins.model.Jenkins;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.jenkinsci.plugins.structs.describable.CustomDescribableModel;
import org.jenkinsci.plugins.structs.describable.DescribableModel;
import org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable;
Expand Down Expand Up @@ -305,7 +305,7 @@
public String getContextEncoded() {
final String context = getContext();
//Functions.jsStringEscape() is also an alternative though the one below escapes more stuff
return context != null ? StringEscapeUtils.escapeJavaScript(context) : null;
return context != null ? StringEscapeUtils.escapeEcmaScript(context) : null;

Check warning on line 308 in src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 308 is not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch(document.querySelector('#params').dataset.descriptor + '/parameters?job=' + encodeURIComponent(document.getElementById(document.querySelector('#params').dataset.jobfield).value) + '&amp;context=${descriptor.contextEncoded}').then((rsp) => {
should be fixed to use data-* attributes idiomatically, in which case we should not need either of these lib deps.

}

public FormValidation doCheckPropagate(@QueryParameter boolean value, @QueryParameter boolean wait) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example of a completely gratuitous use of StringUtils that would better be replaced with a simpler idiom using only types defined in the Java Platform.

import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.steps.StepContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import jenkins.scm.impl.mock.MockSCMDiscoverBranches;
import jenkins.scm.impl.mock.MockSCMNavigator;
import jenkins.security.QueueItemAuthenticatorConfiguration;
import org.apache.commons.lang.StringUtils;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
Expand Down Expand Up @@ -270,11 +269,14 @@ public void buildParallelTests() throws Exception {
p2.getBuildersList().add(new SleepBuilder(1));

WorkflowJob foo = j.jenkins.createProject(WorkflowJob.class, "foo");
foo.setDefinition(new CpsFlowDefinition(StringUtils.join(Collections.singletonList("parallel(test1: {\n" +
" build('test1');\n" +
" }, test2: {\n" +
" build('test2');\n" +
" })"), "\n"), true));
foo.setDefinition(new CpsFlowDefinition("""
parallel(test1: {
build('test1');
}, test2: {
build('test2');
}
)
""", true));

j.buildAndAssertSuccess(foo);
}
Expand All @@ -286,7 +288,9 @@ public void abortBuild() throws Exception {
p.getBuildersList().add(new SleepBuilder(Long.MAX_VALUE));

WorkflowJob foo = j.jenkins.createProject(WorkflowJob.class, "foo");
foo.setDefinition(new CpsFlowDefinition(StringUtils.join(Collections.singletonList("build('test1');"), "\n"), true));
foo.setDefinition(new CpsFlowDefinition("""
build('test1');
""", true));

QueueTaskFuture<WorkflowRun> q = foo.scheduleBuild2(0);
WorkflowRun b = q.getStartCondition().get();
Expand Down Expand Up @@ -333,7 +337,9 @@ public void cancelBuildQueue() throws Exception {
p.getBuildersList().add(new SleepBuilder(Long.MAX_VALUE));

WorkflowJob foo = j.jenkins.createProject(WorkflowJob.class, "foo");
foo.setDefinition(new CpsFlowDefinition(StringUtils.join(Collections.singletonList("build('test1');"), "\n"), true));
foo.setDefinition(new CpsFlowDefinition("""
build('test1');
""", true));

j.jenkins.setNumExecutors(0); //should force freestyle build to remain in the queue?

Expand Down
Loading