Skip to content

Commit e14ab06

Browse files
authored
Merge pull request jenkinsci#180 from jglick/pipeline-groovy-lib
[JENKINS-57023] Switch dep from `workflow-cps-global-lib` to `pipeline-groovy-lib`
2 parents c169a13 + 30ccac8 commit e14ab06

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

pom.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ THE SOFTWARE.
6464
</pluginRepositories>
6565
<properties>
6666
<changelist>999999-SNAPSHOT</changelist>
67-
<jenkins.version>2.289.1</jenkins.version>
67+
<jenkins.version>2.303.3</jenkins.version>
6868
<no-test-jar>false</no-test-jar>
6969
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
7070
</properties>
7171
<dependencyManagement>
7272
<dependencies>
7373
<dependency>
7474
<groupId>io.jenkins.tools.bom</groupId>
75-
<artifactId>bom-2.289.x</artifactId>
75+
<artifactId>bom-2.303.x</artifactId>
7676
<version>1289.v5c4b_1c43511b_</version>
7777
<scope>import</scope>
7878
<type>pom</type>
@@ -137,8 +137,9 @@ THE SOFTWARE.
137137
<scope>test</scope>
138138
</dependency>
139139
<dependency>
140-
<groupId>org.jenkins-ci.plugins.workflow</groupId>
141-
<artifactId>workflow-cps-global-lib</artifactId>
140+
<groupId>io.jenkins.plugins</groupId>
141+
<artifactId>pipeline-groovy-lib</artifactId>
142+
<version>589.vb_a_b_4a_a_8c443c</version> <!-- TODO until in BOM -->
142143
<scope>test</scope>
143144
</dependency>
144145
<dependency>

src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMVarTest.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,26 @@
2424

2525
package org.jenkinsci.plugins.workflow.multibranch;
2626

27-
import hudson.ExtensionList;
28-
import hudson.model.RootAction;
27+
import hudson.FilePath;
28+
import hudson.model.Run;
29+
import hudson.model.TaskListener;
2930
import java.io.File;
3031
import java.nio.file.Files;
32+
import java.util.Arrays;
3133
import jenkins.branch.BranchProperty;
3234
import jenkins.branch.BranchSource;
3335
import jenkins.branch.DefaultBranchPropertyStrategy;
36+
import jenkins.model.Jenkins;
3437
import jenkins.plugins.git.GitSCMSource;
3538
import jenkins.plugins.git.GitSampleRepoRule;
3639
import jenkins.plugins.git.GitStep;
3740
import org.apache.commons.io.FileUtils;
3841
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition;
39-
import org.jenkinsci.plugins.workflow.cps.global.WorkflowLibRepository;
4042
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
4143
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
44+
import org.jenkinsci.plugins.workflow.libs.GlobalLibraries;
45+
import org.jenkinsci.plugins.workflow.libs.LibraryConfiguration;
46+
import org.jenkinsci.plugins.workflow.libs.LibraryRetriever;
4247
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
4348
import org.junit.Test;
4449
import static org.junit.Assert.*;
@@ -90,8 +95,12 @@ public class SCMVarTest {
9095
story.addStep(new Statement() {
9196
@Override public void evaluate() throws Throwable {
9297
// Set up a standardJob definition:
93-
WorkflowLibRepository repo = ExtensionList.lookup(RootAction.class).get(WorkflowLibRepository.class);
94-
File vars = new File(repo.workspace, /*UserDefinedGlobalVariable.PREFIX*/ "vars");
98+
File lib = new File(Jenkins.get().getRootDir(), "somelib");
99+
LibraryConfiguration cfg = new LibraryConfiguration("somelib", new LocalRetriever(lib));
100+
cfg.setImplicit(true);
101+
cfg.setDefaultVersion("fixed");
102+
GlobalLibraries.get().setLibraries(Arrays.asList(cfg));
103+
File vars = new File(lib, "vars");
95104
Files.createDirectories(vars.toPath());
96105
FileUtils.writeStringToFile(new File(vars, "standardJob.groovy"),
97106
"def call(body) {\n" +
@@ -121,6 +130,20 @@ public class SCMVarTest {
121130
});
122131
}
123132

133+
// TODO copied from GrapeTest along with body of libroot(); could make sense as a *-tests.jar utility
134+
private static final class LocalRetriever extends LibraryRetriever {
135+
private final File lib;
136+
LocalRetriever(File lib) {
137+
this.lib = lib;
138+
}
139+
@Override public void retrieve(String name, String version, boolean changelog, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception {
140+
new FilePath(lib).copyRecursiveTo(target);
141+
}
142+
@Override public void retrieve(String name, String version, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception {
143+
retrieve(name, version, false, target, run, listener);
144+
}
145+
}
146+
124147
@Issue("JENKINS-31386")
125148
@Test public void standaloneProject() {
126149
story.addStep(new Statement() {

0 commit comments

Comments
 (0)