-
Improvement
-
Resolution: Won't Fix
-
Minor
-
None
-
Jenkins: 1.625.3
Workflow plugin: 1.11
It should be possible to import shared Groovy code from the SCM source in a Workflow job. For instance, if my workflow script (flow.groovy) needs to access variables from another script (constants.groovy) and they are both in the SCM repo that the Workflow job checked out, it should be simple to do. It's not and currently the unabashedly terrible workaround is to do this:
def constants stage('Import dependencies') node{ git(url: 'ssh://git@mygitserver.com:7999/ex/workflow.git', credentialsId: '60cda0cc-f13d-448c-9947-28b926a20628') constants = load('constants.groovy') }
This works, but the fact that another node has to be spun up and another git checkout command is required is awful. It should be pretty straightfoward to have Jenkins simply load one of these files. Something like this:
constants = import("constants.groovy")
I'm pretty sure Groovy won't let you use "import" since it's a resered keyword, but I don't have any particularly strong feelings about the semantics of this command. I just want a way to load these files easily.
- depends on
-
JENKINS-33273 Optimize Jenkinsfile loading and branch detection
- Resolved
- is related to
-
JENKINS-31155 Workflow shared library improvements
- Closed
-
JENKINS-34596 Set visible flag when Jenkinsfile is taken from a trusted revision rather than PR head
- Resolved