Skip to content

Commit d6273c0

Browse files
authored
[JENKINS-56682] Reproduce and fix issue using types from shared libraries in Script initializers (#71)
1 parent 95ebc4c commit d6273c0

File tree

2 files changed

+41
-20
lines changed

2 files changed

+41
-20
lines changed

pom.xml

+23-20
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,20 @@
6767
<jenkins.version>2.138.4</jenkins.version>
6868
<java.level>8</java.level>
6969
<useBeta>true</useBeta>
70-
<workflow-cps-plugin.version>2.69</workflow-cps-plugin.version>
70+
<workflow-cps-plugin.version>2.71</workflow-cps-plugin.version>
7171
<git-plugin.version>4.0.0-rc</git-plugin.version>
72-
<scm-api-plugin.version>2.3.0</scm-api-plugin.version>
73-
<workflow-scm-step-plugin.version>2.4</workflow-scm-step-plugin.version>
74-
<workflow-multibranch-plugin.version>2.10</workflow-multibranch-plugin.version>
75-
<workflow-step-api-plugin.version>2.19</workflow-step-api-plugin.version>
72+
<scm-api-plugin.version>2.4.0</scm-api-plugin.version>
73+
<workflow-scm-step-plugin.version>2.7</workflow-scm-step-plugin.version>
74+
<workflow-multibranch-plugin.version>2.21</workflow-multibranch-plugin.version>
75+
<workflow-step-api-plugin.version>2.20</workflow-step-api-plugin.version>
7676
<workflow-support-plugin.version>3.3</workflow-support-plugin.version>
7777
</properties>
7878
<dependencies>
79+
<dependency>
80+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
81+
<artifactId>workflow-api</artifactId>
82+
<version>2.33</version>
83+
</dependency>
7984
<dependency>
8085
<groupId>org.jenkins-ci.plugins.workflow</groupId>
8186
<artifactId>workflow-cps</artifactId>
@@ -105,7 +110,7 @@
105110
<dependency>
106111
<groupId>org.jenkins-ci.plugins</groupId>
107112
<artifactId>cloudbees-folder</artifactId>
108-
<version>6.1.0</version>
113+
<version>6.1.2</version>
109114
</dependency>
110115
<dependency>
111116
<groupId>org.jenkins-ci.plugins.workflow</groupId>
@@ -115,17 +120,17 @@
115120
<dependency>
116121
<groupId>org.jenkins-ci.plugins</groupId>
117122
<artifactId>script-security</artifactId>
118-
<version>1.58</version>
123+
<version>1.60</version>
119124
</dependency>
120125
<dependency>
121126
<groupId>org.jenkins-ci.plugins</groupId>
122127
<artifactId>structs</artifactId>
123-
<version>1.18</version>
128+
<version>1.19</version>
124129
</dependency>
125130
<dependency>
126131
<groupId>org.jenkins-ci.plugins</groupId>
127132
<artifactId>credentials</artifactId>
128-
<version>2.1.14</version>
133+
<version>2.1.18</version>
129134
</dependency>
130135
<dependency>
131136
<groupId>org.apache.ivy</groupId>
@@ -152,19 +157,19 @@
152157
<dependency>
153158
<groupId>org.jenkins-ci.plugins.workflow</groupId>
154159
<artifactId>workflow-job</artifactId>
155-
<version>2.9</version>
160+
<version>2.32</version>
156161
<scope>test</scope>
157162
</dependency>
158163
<dependency>
159164
<groupId>org.jenkins-ci.plugins.workflow</groupId>
160165
<artifactId>workflow-basic-steps</artifactId>
161-
<version>2.3</version>
166+
<version>2.15</version>
162167
<scope>test</scope>
163168
</dependency>
164169
<dependency>
165170
<groupId>org.jenkins-ci.plugins.workflow</groupId>
166171
<artifactId>workflow-durable-task-step</artifactId>
167-
<version>2.8</version>
172+
<version>2.28</version>
168173
<scope>test</scope>
169174
</dependency>
170175
<dependency>
@@ -180,13 +185,6 @@
180185
<classifier>tests</classifier>
181186
<scope>test</scope>
182187
</dependency>
183-
<dependency>
184-
<groupId>org.jenkins-ci.plugins.workflow</groupId>
185-
<artifactId>workflow-scm-step</artifactId>
186-
<version>${workflow-scm-step-plugin.version}</version>
187-
<classifier>tests</classifier>
188-
<scope>test</scope>
189-
</dependency>
190188
<dependency>
191189
<groupId>org.jenkins-ci.plugins.workflow</groupId>
192190
<artifactId>workflow-step-api</artifactId>
@@ -267,12 +265,17 @@
267265
<dependency>
268266
<groupId>org.jenkins-ci.plugins</groupId>
269267
<artifactId>branch-api</artifactId>
270-
<version>2.0.21</version>
268+
<version>2.2.0</version>
271269
<scope>test</scope>
272270
</dependency>
273271
</dependencies>
274272
<dependencyManagement>
275273
<dependencies>
274+
<dependency>
275+
<groupId>org.jenkins-ci.plugins</groupId>
276+
<artifactId>apache-httpcomponents-client-4-api</artifactId>
277+
<version>4.5.5-3.0</version>
278+
</dependency>
276279
<dependency>
277280
<groupId>org.jenkins-ci.plugins</groupId>
278281
<artifactId>git-client</artifactId>

src/test/java/org/jenkinsci/plugins/workflow/libs/LibraryAdderTest.java

+18
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,22 @@ public class LibraryAdderTest {
336336
r.assertLogContains("set to loaded null", r.buildAndAssertSuccess(p));
337337
}
338338

339+
@Issue("JENKINS-56682")
340+
@Test public void scriptFieldsWhereInitializerUsesLibrary() throws Exception {
341+
sampleRepo.init();
342+
sampleRepo.write("src/pkg/Foo.groovy", "package pkg; class Foo { }");
343+
sampleRepo.git("add", "src");
344+
sampleRepo.git("commit", "--message=init");
345+
GlobalLibraries.get().setLibraries(Collections.singletonList(
346+
new LibraryConfiguration("lib",
347+
new SCMSourceRetriever(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", true)))));
348+
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
349+
p.setDefinition(new CpsFlowDefinition(
350+
"@Library('lib@master') import pkg.Foo\n" +
351+
"import groovy.transform.Field\n" +
352+
"@Field f = new Foo()\n" +
353+
"@Field static g = new Foo()\n", true));
354+
r.buildAndAssertSuccess(p);
355+
}
356+
339357
}

0 commit comments

Comments
 (0)