#x27; character in environment variable's value is doubled in when used in the pipeline's container step

'
#x27; character in environment variable's value is doubled in when used in the pipeline's container step

8/1/2019

I use the kubernetes plugin in a jenkins pipeline to run the stages in containers and I inject username password credentials as environment variables into the containers using the Credentials Binding Plugin. Some of the passwords have dollar sign in them and inside the container step those dollar signs somehow get doubled. I've narrowed down and it seems to be specific to environment variables(the credential bindings will define environment variables too), so I've created a simple pipeline testing this:

pipeline {
    agent any
    environment {
        FRUIT = 'apple$'
    }
    stages {
        stage('test') {
            steps {
                sh 'echo "${FRUIT}"'
                container('jnlp') {
                    sh 'echo "${FRUIT}"'
                }
            }
        }
    }
}

The output:

apple$
apple$$

The second line is printed from the container step, same variable, but the dollar sign at the end is doubled.

Versions: - Jenkins 2.176.2 - Pipeline 2.6 - Kubernetes plugin 1.18.0

  • Kubernetes cluster v1.14.4

Does it suppose to work or is there some limitation with the container step?

-- netfalo
jenkins
jenkins-pipeline
jenkins-plugins
kubernetes

0 Answers