Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jenkins error script.sh与ansicolor一起放入otput_Jenkins_Jenkins Pipeline - Fatal编程技术网

Jenkins error script.sh与ansicolor一起放入otput

Jenkins error script.sh与ansicolor一起放入otput,jenkins,jenkins-pipeline,Jenkins,Jenkins Pipeline,我正在尝试使用ansicolor在jenkins中为sh命令着色。问题是,当我执行它时,我遇到了以下错误(只是提到git是作为拉入步骤安装的,它成功完成了),这是我用于sh命令的脚本: node { stage ('Pulling code from Bitbucket') { git branch: 'master', credentialsId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',

我正在尝试使用ansicolor在jenkins中为sh命令着色。问题是,当我执行它时,我遇到了以下错误(只是提到git是作为拉入步骤安装的,它成功完成了),这是我用于sh命令的脚本:

node {

    stage ('Pulling code from Bitbucket') {


        git branch: 'master',
                credentialsId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                url: 'git@bitbucket.org:xxxxx/test.git'


                wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {

               sh ("""\033[35mgit branch\033[0m""")

               }

               }

          }

如果我在不使用ansicolor的情况下使用
sh'git branch'
命令,它工作正常:

[workspace] Running shell script
+ git branch
* master
我还尝试使用returnStdout检查是否可以像这样传递sh命令输出:

node {

    stage ('Pulling code from Bitbucket') {


        git branch: 'master',
                credentialsId: '2bbc73c4-254e-45bd-85f4-6a169699310c',
                url: 'git@bitbucket.org:xxxxx/test.git'



          script {
               //VAR = sh("""returnStdout: true, script: 'git branch """)

               //println "${VAR}"

               }
我也得到了和ansicolor一样的错误,就像这样

这与什么有关?谢谢-

(编辑)


您的
sh
语法不正确。正确的语法是:

sh returnStdout: true, script: 'git branch'

是的,我检查过了,现在stdout还可以,但是仍然找不到ansicolo。可以为sh命令着色吗?或者只是Echo和println。我该怎么做?println和echo“something”工作正常,但像“git status”或“git branch”这样的常规sh命令会被着色,但我会得到:dustable-d61b2999/script.sh:git:not foundis installed if not code本来就不会被提取检查整个代码。如果我在没有ansicolor的情况下执行git状态或git分支,它会工作。如果我用asnicolor做的话,它会抛出我正在展示的错误,而主机已经安装了它。它没有安装在slave.chek最后一个映像上。如果我在公共打印中使用颜色,它会显示输出。但如果我按sh的命令做的话,我就不会。这就是问题所在。正如您所看到的,git已经安装并且工作正常