Jenkins 管道将环境变量写入 ~/.bash_profile

时间:2021-02-15 13:50:23

标签: bash jenkins jenkins-pipeline

我需要我的 Jenkinsfile 管道将变量输入到我的 ~/.bash_profile 文件中。 当我在我的服务器上时,我只需输入:

echo 'export VARIABLE_NAME=variable_value' >> ~/.bash_profile

所以,我在我的 Jenkinsfile 中尝试类似的东西:

stage("Def environment variable") {
            steps {
                sh "echo 'export VARIABLE_NAME=variable_value' >> ~/.bash_profile"
            }
}

那个,

stage("Def environment variable") {
            steps {
                script {
                    writeFile file: '~/.bash_profile', text: "VARIABLE_NAME=variable_value"
                }
            }
}

但这两个选项不起作用。您对如何做到这一点有任何解决方案或建议吗?谢谢!

0 个答案:

没有答案