Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47600

Declarative environment hangs on overwriting self with existing env.value

    Details

    • Similar Issues:

      Description

      After upgrading from v1.1.9 to v1.2.2 (and even v1.2.3 as of yesterday), our pipelines started to hang.  This seems to be related to JENKINS-45198.  Showing the pipeline steps was the key to figure this out  as it was stuck in "Set environment variables" (See attachment)

      BlueOcean would say: Queued Waiting for run to start

      Console would say:

      [Pipeline] { (Declarative: Checkout SCM)
      [Pipeline] checkout
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url ... # timeout=10
      Fetching without tags
      Fetching upstream changes from ...
       > git --version # timeout=10
      using GIT_ASKPASS to set credentials Jenkins Github password
       > git fetch --no-tags --progress ...
      Checking out Revision d6a063e9118ab507621bdf42ce9baa67fc07d5f4 (master)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f d6a063e9118ab507621bdf42ce9baa67fc07d5f4
      Commit message: "v2.0.65 changelog"
       > git rev-list d6a063e9118ab507621bdf42ce9baa67fc07d5f4 # timeout=10
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] withEnv
      [Pipeline] {

      This is with all plugins and jenkins up to date as of today.

      Jenkinsfile attached

      Many thanks for any help/light you can shine on this

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            I believe that's because of this line:

                   BRANCH = "${env.BRANCH}"
            

            I'm not 100% sure whether that's due to you trying to set something to its own value (which is what you're doing there) or because you're trying to override a parameter (albeit with its own value again!). Regardless, that line is completely superfluous and if you remove it, you'll be good to go. I'll investigate to figure out exactly what the hang is being caused by to see if I can prevent this.

            Show
            abayer Andrew Bayer added a comment - I believe that's because of this line: BRANCH = "${env.BRANCH}" I'm not 100% sure whether that's due to you trying to set something to its own value (which is what you're doing there) or because you're trying to override a parameter (albeit with its own value again!). Regardless, that line is completely superfluous and if you remove it, you'll be good to go. I'll investigate to figure out exactly what the hang is being caused by to see if I can prevent this.
            Hide
            adrianbridgett Adrian Bridgett added a comment -

            Gosh, that was a fast reply - thanks Andrew!  I'm not quite sure what I was thinking either   I wonder if at some point it was more BRANCH=${env.GIT_BRANCH} or similar.  I'll go and confirm that this fixes it. 

             

            Show
            adrianbridgett Adrian Bridgett added a comment - Gosh, that was a fast reply - thanks Andrew!  I'm not quite sure what I was thinking either   I wonder if at some point it was more BRANCH=${env.GIT_BRANCH} or similar.  I'll go and confirm that this fixes it.   
            Hide
            abayer Andrew Bayer added a comment -

            No worries - I've changed the summary so that I know what this JIRA is for in the future. =)

            Show
            abayer Andrew Bayer added a comment - No worries - I've changed the summary so that I know what this JIRA is for in the future. =)
            Hide
            abayer Andrew Bayer added a comment -

            Got a more minimal reproduction case:

            pipeline {
                agent none
                environment {
                    VALUE = "first"
                }
                stages {
                    stage("foo") {
                        environment {
                            VALUE = "${env.VALUE} second"
                        }
                        steps {
                            echo "value: ${VALUE}"
                        }
                    }
                }
            }
            

            I haven't nailed down the hang yet, but it only happens with env.VALUE, not VALUE, which is suggestive.

            Show
            abayer Andrew Bayer added a comment - Got a more minimal reproduction case: pipeline { agent none environment { VALUE = "first" } stages { stage( "foo" ) { environment { VALUE = "${env.VALUE} second" } steps { echo "value: ${VALUE}" } } } } I haven't nailed down the hang yet, but it only happens with env.VALUE , not VALUE , which is suggestive.
            Hide
            abayer Andrew Bayer added a comment -

            got it - https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/211 - we had special casing for when you're referencing the env var in its value with VALUE syntax, but not for env.VALUE. So the PR adds that and we're good to go.

            Show
            abayer Andrew Bayer added a comment - got it - https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/211 - we had special casing for when you're referencing the env var in its value with VALUE syntax, but not for env.VALUE . So the PR adds that and we're good to go.
            Hide
            adrianbridgett Adrian Bridgett added a comment -

            Fab - I've got to wait for some long running jobs to finish before I can confirm that other fix, I've not forgotten (yet!)

            Show
            adrianbridgett Adrian Bridgett added a comment - Fab - I've got to wait for some long running jobs to finish before I can confirm that other fix, I've not forgotten (yet!)
            Hide
            abayer Andrew Bayer added a comment -

            No worries. =)

            Show
            abayer Andrew Bayer added a comment - No worries. =)
            Hide
            adrianbridgett Adrian Bridgett added a comment -

            Confirmed - removing my crap code makes it all work   Thanks again Andrew

            Show
            adrianbridgett Adrian Bridgett added a comment - Confirmed - removing my crap code makes it all work   Thanks again Andrew

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                adrianbridgett Adrian Bridgett
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: