-
Notifications
You must be signed in to change notification settings - Fork 902
[JENKINS-30222] Multibranch/global var incompatibility #198
Conversation
@@ -208,13 +206,13 @@ public class SCMBinderTest {
" body.delegate = config\n" +
" body()\n" +
" node {\n" +
- " checkout scm\n" +
+ " checkout config.scm\n" +
" echo \"loaded ${readFile config.file}\"\n" +
" }\n" +
"}\n");
// Then a project using it:
sampleGitRepo.init();
- sampleGitRepo.write("Jenkinsfile", "standardJob {file = 'resource'}");
+ sampleGitRepo.write("Jenkinsfile", "def _scm = scm; standardJob {scm = _scm; file = 'resource'}");
sampleGitRepo.write("resource", "resource content");
sampleGitRepo.git("add", "Jenkinsfile");
sampleGitRepo.git("add", "resource"); works but the |
This also works, and has the benefit of making the library code comprehensible to mere mortals, though it is still a little cumbersome on the @@ -202,19 +200,15 @@ public class SCMBinderTest {
File vars = new File(repo.workspace, /*UserDefinedGlobalVariable.PREFIX*/ "vars");
vars.mkdirs();
FileUtils.writeStringToFile(new File(vars, "standardJob.groovy"),
- "def call(body) {\n" +
- " def config = [:]\n" +
- " body.resolveStrategy = Closure.DELEGATE_FIRST\n" +
- " body.delegate = config\n" +
- " body()\n" +
+ "def call(config) {\n" +
" node {\n" +
- " checkout scm\n" +
+ " checkout config.scm\n" +
" echo \"loaded ${readFile config.file}\"\n" +
" }\n" +
"}\n");
// Then a project using it:
sampleGitRepo.init();
- sampleGitRepo.write("Jenkinsfile", "standardJob {file = 'resource'}");
+ sampleGitRepo.write("Jenkinsfile", "standardJob scm: scm, file: 'resource'");
sampleGitRepo.write("resource", "resource content");
sampleGitRepo.git("add", "Jenkinsfile");
sampleGitRepo.git("add", "resource"); |
Working on using |
Nothing I try with
Suppose a build used a library and tried to access |
The best I could manage so far. @reviewbybees esp. @kohsuke |
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
If I understand correctly, this test demonstrates a problem and provides a workaround, which is not very graceful. Is is correct? 🐝 if yes |
The solution, as I understand it, does seem too funky. From what I read here, seems to me like the best solution is to use an Actions have always seemed cumbersome to me as a way of storing state. It seems to me like there's a need for a general purpose context storage scoped at different levels ( |
Correct. cdfee0a (the first commit) demonstrates what I expected to work at the start. Basically remove the My current thinking is that the messy list of scopes could be cleaned up (and this problem solved) if we created a special
|
🐝 |
Filed JENKINS-30222 to track improvements. |
[JENKINS-30222] Multibranch/global var incompatibility
@kohsuke FYI