Details
-
Improvement
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
Description
In a Declarative Pipeilne which defines an environment variable which is derivative of a built-in, e.g.
pipeline { environment { MY_SHA=GIT_COMMIT } }
This results in this error:
hudson.remoting.ProxyException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: /var/jenkins_home/jobs/cloudbees-training/jobs/training-commons/branches/PR-143/builds/1/libs/training-commons/vars/commonTrainingPipeline.groovy: 16: Environment variable values must either be strings or function calls. @ line 16, column 24. MY_SHA=GIT_COMMIT ^ /var/jenkins_home/jobs/cloudbees-training/jobs/training-commons/branches/PR-143/builds/1/libs/training-commons/vars/commonTrainingPipeline.groovy: 13: No variables specified for environment @ line 13, column 5. environment { ^ 2 errors at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
The easy solution here is to quote the variable, e.g.:
environment {
MY_SHA="${GIT_COMMIT}"
}
I understand why this is so, but I think the error message and the resulting solution are confusing and not intuitive to most Declarative Pipeline users.
A better, more task-oriented error message would be helfpful IMHO
Attachments
Issue Links
- links to
Activity
Field | Original Value | New Value |
---|---|---|
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | In Review [ 10005 ] |
Remote Link | This issue links to "PR #238 (Web Link)" [ 19894 ] |
Resolution | Fixed [ 1 ] | |
Status | In Review [ 10005 ] | Resolved [ 5 ] |
Status | Resolved [ 5 ] | Closed [ 6 ] |