问题
I want to hide jenkins sh execute command in pipeline
pipeline {
agent any
stages {
stage('Load Lib') {
steps {
sh "ls -al /"
}
}
}
}
Current result:
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Load Lib)
[Pipeline] sh
[Test] Running shell script
+ ls -al /
I want to hide Running shell script ls -al / command in output.
Please help
回答1:
This is definitely related to Echo off in Jenkins Console Output
For pipeline, what this means is:
pipeline {
agent any
stages {
stage('Load Lib') {
steps {
sh '''
set +x
s -al
set -x
'''
}
}
}
}
'''
indicates a multi line command. set +x
turns off command echoing, and set -x
turns it back on again.
回答2:
You can override this behaviour for the whole script by putting the following at the top of the build step:
#!/bin/bash +x
来源:https://stackoverflow.com/questions/47523909/hide-command-executed-only-show-output