Skip to content

Commit 7329664

Browse files
committed
Merge remote-tracking branch 'upstream/master' into JENKINS-69731-scm-BRANCH_NAME
2 parents 7926f8c + 0c6467c commit 7329664

File tree

3 files changed

+53
-33
lines changed

3 files changed

+53
-33
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<parent>
2929
<groupId>org.jenkins-ci.plugins</groupId>
3030
<artifactId>plugin</artifactId>
31-
<version>4.75</version>
31+
<version>4.76</version>
3232
<relativePath/>
3333
</parent>
3434
<groupId>io.jenkins.plugins</groupId>
@@ -63,15 +63,15 @@
6363
</pluginRepositories>
6464
<properties>
6565
<changelist>999999-SNAPSHOT</changelist>
66-
<jenkins.version>2.361.4</jenkins.version>
66+
<jenkins.version>2.414.3</jenkins.version>
6767
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
6868
</properties>
6969
<dependencyManagement>
7070
<dependencies>
7171
<dependency>
7272
<groupId>io.jenkins.tools.bom</groupId>
73-
<artifactId>bom-2.361.x</artifactId>
74-
<version>2102.v854b_fec19c92</version>
73+
<artifactId>bom-2.414.x</artifactId>
74+
<version>2705.vf5c48c31285b_</version>
7575
<scope>import</scope>
7676
<type>pom</type>
7777
</dependency>

src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryStep.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import edu.umd.cs.findbugs.annotations.CheckForNull;
6161
import edu.umd.cs.findbugs.annotations.NonNull;
6262
import groovy.lang.MissingPropertyException;
63-
import javax.inject.Inject;
6463
import jenkins.model.Jenkins;
6564
import jenkins.scm.impl.SingleSCMSource;
6665
import org.codehaus.groovy.control.MultipleCompilationErrorsException;
@@ -70,10 +69,11 @@
7069
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
7170
import org.jenkinsci.plugins.workflow.cps.CpsThread;
7271
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
73-
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
74-
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
75-
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;
76-
import org.jenkinsci.plugins.workflow.steps.StepContextParameter;
72+
import org.jenkinsci.plugins.workflow.steps.Step;
73+
import org.jenkinsci.plugins.workflow.steps.StepContext;
74+
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
75+
import org.jenkinsci.plugins.workflow.steps.StepExecution;
76+
import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution;
7777
import org.kohsuke.accmod.Restricted;
7878
import org.kohsuke.accmod.restrictions.DoNotUse;
7979
import org.kohsuke.groovy.sandbox.GroovyInterceptor;
@@ -86,7 +86,7 @@
8686
/**
8787
* Dynamically injects a library into the running build.
8888
*/
89-
public class LibraryStep extends AbstractStepImpl {
89+
public class LibraryStep extends Step {
9090

9191
private static final Logger LOGGER = Logger.getLogger(LibraryStep.class.getName());
9292

@@ -118,11 +118,11 @@ public Boolean getChangelog() {
118118
this.changelog = changelog;
119119
}
120120

121-
@Extension public static class DescriptorImpl extends AbstractStepDescriptorImpl {
121+
@Override public StepExecution start(StepContext context) throws Exception {
122+
return new Execution(this, context);
123+
}
122124

123-
public DescriptorImpl() {
124-
super(Execution.class);
125-
}
125+
@Extension public static class DescriptorImpl extends StepDescriptor {
126126

127127
@Override public String getFunctionName() {
128128
return "library";
@@ -132,6 +132,10 @@ public DescriptorImpl() {
132132
return "Load a library on the fly";
133133
}
134134

135+
@Override public Set<? extends Class<?>> getRequiredContext() {
136+
return Set.of(Run.class, TaskListener.class, FlowExecution.class);
137+
}
138+
135139
@Restricted(DoNotUse.class) // Jelly
136140
public Collection<LibraryRetrieverDescriptor> getRetrieverDescriptors() {
137141
return Jenkins.get().getDescriptorByType(LibraryConfiguration.DescriptorImpl.class).getRetrieverDescriptors();
@@ -157,15 +161,20 @@ public AutoCompletionCandidates doAutoCompleteIdentifier(@AncestorInPath ItemGro
157161

158162
}
159163

160-
public static class Execution extends AbstractSynchronousNonBlockingStepExecution<LoadedClasses> {
164+
public static class Execution extends SynchronousNonBlockingStepExecution<LoadedClasses> {
161165

162166
private static final long serialVersionUID = 1L;
163167

164-
@Inject private transient LibraryStep step;
165-
@StepContextParameter private transient Run<?,?> run;
166-
@StepContextParameter private transient TaskListener listener;
168+
private transient final LibraryStep step;
169+
170+
Execution(LibraryStep step, StepContext context) {
171+
super(context);
172+
this.step = step;
173+
}
167174

168175
@Override protected LoadedClasses run() throws Exception {
176+
Run<?,?> run = getContext().get(Run.class);
177+
TaskListener listener = getContext().get(TaskListener.class);
169178
String[] parsed = LibraryAdder.parse(step.identifier);
170179
String name = parsed[0], version = parsed[1];
171180
boolean trusted = false;
@@ -204,9 +213,9 @@ public static class Execution extends AbstractSynchronousNonBlockingStepExecutio
204213
// uses the library step with a non-null retriever to check out a static version of the library.
205214
// Fixing this would require us being able to detect usage of SCMVar precisely, which is not currently possible.
206215
else if (retriever instanceof SCMRetriever) {
207-
verifyRevision(((SCMRetriever) retriever).getScm(), name);
216+
verifyRevision(((SCMRetriever) retriever).getScm(), name, run, listener);
208217
} else if (retriever instanceof SCMSourceRetriever && ((SCMSourceRetriever) retriever).getScm() instanceof SingleSCMSource) {
209-
verifyRevision(((SingleSCMSource) ((SCMSourceRetriever) retriever).getScm()).getScm(), name);
218+
verifyRevision(((SingleSCMSource) ((SCMSourceRetriever) retriever).getScm()).getScm(), name, run, listener);
210219
}
211220

212221
LibraryRecord record = new LibraryRecord(name, version, trusted, changelog, cachingConfiguration, source);
@@ -236,9 +245,9 @@ else if (retriever instanceof SCMRetriever) {
236245
return new LoadedClasses(name, record.getDirectoryName(), trusted, changelog, run);
237246
}
238247

239-
private void verifyRevision(SCM scm, String name) throws IOException, InterruptedException {
248+
private void verifyRevision(SCM scm, String name, Run<?,?> run, TaskListener listener) throws IOException, InterruptedException {
240249
for (LibraryStepRetrieverVerifier revisionVerifier : LibraryStepRetrieverVerifier.all()) {
241-
revisionVerifier.verify(this.run, listener, scm, name);
250+
revisionVerifier.verify(run, listener, scm, name);
242251
}
243252
}
244253

src/main/java/org/jenkinsci/plugins/workflow/libs/ResourceStep.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,21 @@
2929
import hudson.Util;
3030
import java.util.Map;
3131
import edu.umd.cs.findbugs.annotations.CheckForNull;
32-
import javax.inject.Inject;
32+
import java.util.Set;
3333
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
3434
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
35-
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
36-
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
37-
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution;
35+
import org.jenkinsci.plugins.workflow.steps.Step;
36+
import org.jenkinsci.plugins.workflow.steps.StepContext;
37+
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
38+
import org.jenkinsci.plugins.workflow.steps.StepExecution;
39+
import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
3840
import org.kohsuke.stapler.DataBoundConstructor;
3941
import org.kohsuke.stapler.DataBoundSetter;
4042

4143
/**
4244
* Step to load a resource from a library.
4345
*/
44-
public class ResourceStep extends AbstractStepImpl {
46+
public class ResourceStep extends Step {
4547

4648
private final String resource;
4749
private String encoding;
@@ -67,11 +69,11 @@ public String getResource() {
6769
this.encoding = Util.fixEmptyAndTrim(encoding);
6870
}
6971

70-
@Extension public static class DescriptorImpl extends AbstractStepDescriptorImpl {
72+
@Override public StepExecution start(StepContext context) throws Exception {
73+
return new Execution(this, context);
74+
}
7175

72-
public DescriptorImpl() {
73-
super(Execution.class);
74-
}
76+
@Extension public static class DescriptorImpl extends StepDescriptor {
7577

7678
@Override public String getDisplayName() {
7779
return "Load a resource file from a library";
@@ -81,13 +83,22 @@ public DescriptorImpl() {
8183
return "libraryResource";
8284
}
8385

86+
@Override public Set<? extends Class<?>> getRequiredContext() {
87+
return Set.of(FlowExecution.class);
88+
}
89+
8490
}
8591

86-
public static class Execution extends AbstractSynchronousStepExecution<String> {
92+
public static class Execution extends SynchronousStepExecution<String> {
8793

8894
private static final long serialVersionUID = 1L;
8995

90-
@Inject private transient ResourceStep step;
96+
private transient final ResourceStep step;
97+
98+
public Execution(ResourceStep step, StepContext context) {
99+
super(context);
100+
this.step = step;
101+
}
91102

92103
@Override protected String run() throws Exception {
93104
String resource = step.resource;

0 commit comments

Comments
 (0)