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

Backslashes are not correctly reduced when in environment var with substituted value

    XMLWordPrintable

    Details

    • Sprint:
      Pipeline - July/August
    • Similar Issues:

      Description

      Using jenkins pipeline, I have found that an environment property that takes variable substitution (see example below) doesn't get it's backslashes correctly reduced. I would have expected that both keys below start with "a\b". Instead, AAA_Key1 becomes "a
      b 0", while AAA_Key2 becomes "a\b".

       

      Example script

      pipeline {
          agent any
          stages {
              stage('Build') {
                  environment {
                      AAA_Key1 = "a\\b ${EXECUTOR_NUMBER}"
                      AAA_Key2 = "a\\b"
                  }
                  steps {
                      bat 'set'
                  }
              }
          }
      }

      Current Output

      c:\w\Pipeline Experimental\default>set
      AAA_Key1=a\\b 0
      AAA_Key2=a\b
      

      Current workaround is to use withEnv directly, which doesn't appear to suffer from this issue

        Attachments

          Issue Links

            Activity

            peitschie Philip Peitsch created issue -
            peitschie Philip Peitsch made changes -
            Field Original Value New Value
            Description Using jenkins pipeline, I have found that an environment property that takes variable substitution (see example below) doesn't get it's backslashes correctly reduced. I would have expected that both keys below start with "a\b". Instead, AAA_Key1 becomes "a
            b 0", while AAA_Key2 becomes "a\b".

             

            Example script
            {code:java}
            pipeline {
                agent any
                stages {
                    stage('Build') {
                        environment {
                            AAA_Key1 = "a\\b ${EXECUTOR_NUMBER}"
                            AAA_Key2 = "a\\b"
                        }
                        steps {
                            bat 'set'
                        }
                    }
                }
            }{code}
            Current Output
            {code:java}
            c:\w\Pipeline Experimental\default>set
            AAA_Key1=a\\b 0
            AAA_Key2=a\b
            {code}
            Using jenkins pipeline, I have found that an environment property that takes variable substitution (see example below) doesn't get it's backslashes correctly reduced. I would have expected that both keys below start with "a\b". Instead, AAA_Key1 becomes "a
             b 0", while AAA_Key2 becomes "a\b".

             

            Example script
            {code:java}
            pipeline {
                agent any
                stages {
                    stage('Build') {
                        environment {
                            AAA_Key1 = "a\\b ${EXECUTOR_NUMBER}"
                            AAA_Key2 = "a\\b"
                        }
                        steps {
                            bat 'set'
                        }
                    }
                }
            }{code}
            Current Output
            {code:java}
            c:\w\Pipeline Experimental\default>set
            AAA_Key1=a\\b 0
            AAA_Key2=a\b
            {code}

            Current workaround is to use withEnv directly, which doesn't appear to suffer from this issue
            abayer Andrew Bayer made changes -
            Labels declarative-variable-and-method-resolution
            jamesdumay James Dumay made changes -
            Sprint Pipeline - July/August [ 371 ]
            abayer Andrew Bayer made changes -
            Link This issue depends on JENKINS-42753 [ JENKINS-42753 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                peitschie Philip Peitsch
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: