简体   繁体   English

詹金斯:如何在脚本管道中更改外壳?

[英]Jenkins: How to change shell in Scripted Pipeline?

Print default shell with below script.使用以下脚本打印默认 shell。

node {
    stage('Clean'){
        echo "${SHELL}"
...
}

From log, it's /usr/local/bin/tcsh.从日志来看,它是 /usr/local/bin/tcsh。

[Pipeline] echo  
/usr/local/bin/tcsh

How to change it to another shell, like /bin/csh?如何将其更改为另一个 shell,例如 /bin/csh?

Tried below code, echo still prints "/usr/local/bin/tcsh", but suddenly /bin/csh environment variable is available.尝试下面的代码,echo 仍然打印“/usr/local/bin/tcsh”,但突然 /bin/csh 环境变量可用。

stage('Clean'){
        sh '''#!/bin/csh
                echo "Clean old coverage data"
                echo "${SHELL}"
        '''
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM