Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables set in a stage are prematurely applied #434

Open
dblock opened this issue Nov 18, 2021 · 2 comments
Open

Variables set in a stage are prematurely applied #434

dblock opened this issue Nov 18, 2021 · 2 comments

Comments

@dblock
Copy link
Member

dblock commented Nov 18, 2021

Version report

1.12

Reproduction steps

stage('prepare') {
 agent any
 steps {
    script {
       dockerImage = 'docker-image'
    }
 }
}
stage('build') {
  agent {
    docker {
      label 'label'
      image dockerImage
  }
}

Results

Expected result:

image dockerImage should pickup the assigned docker-image label, which works in Jenkins.

Actual result:

Error that dockerImage is undefined.

@dblock dblock added the bug label Nov 18, 2021
dblock added a commit to dblock/JenkinsPipelineUnit that referenced this issue Nov 19, 2021
@dblock
Copy link
Member Author

dblock commented Nov 19, 2021

I reproduced this in https://github.com/dblock/JenkinsPipelineUnit/tree/fix-434, but I couldn't fix it. Deferring evaluation of these variables looks involved. Could use help. /cc: @nre-ableton

com.lesfurets.jenkins.unit.declarative.TestVariableAssignment > test FAILED
    groovy.lang.MissingPropertyException: No such property: dockerImage for class: VariableAssignment_Jenkinsfile
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)

@nre-ableton
Copy link
Contributor

Sorry -- I have no idea about any of the declarative API stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants