[JIRA] (JENKINS-59099) Environment variables with '$' in their content get corrupted in the container step in declerative pipeline

4 views
Skip to first unread message

netfalo+jenkins@gmail.com (JIRA)

unread,
Aug 27, 2019, 6:07:03 AM8/27/19
to jenkinsc...@googlegroups.com
Marcell Lipusz created an issue
 
Jenkins / Bug JENKINS-59099
Environment variables with '$' in their content get corrupted in the container step in declerative pipeline
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2019-08-27 10:06
Environment: stable/jenkins helm chart: 1.5.9
jenkins 2.176.2
kubernets-plugin 1.18.2

the slaves are: jenkins/jnlp-slave:3.27-1
Priority: Minor Minor
Reporter: Marcell Lipusz

Hi,

I have a declarative pipeline, where the pod contains a few containers, during the execution I want to specify where to run a particular step, so I use the container() step. When I declare an environment variable that contains '$' as value and try to use it in the container step the '$' is doubled.

I originally noticed this with the credential-binding plugin, but I figured that it can be reproduced with simply using environment variables.

I've created a simple pipeline to demonstrate:

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

Result:

[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] sh
+ echo $apple
$apple
[Pipeline] container
[Pipeline] {
[Pipeline] sh
+ echo $$apple
$$apple

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

netfalo+jenkins@gmail.com (JIRA)

unread,
Sep 3, 2019, 9:42:05 AM9/3/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages