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
If you need to hide the output without letting the program know it by checking the output/error file descriptor, you can try using the following in a shell: stty flusho; command ;stty -flusho or if you just want to hide input from the terminal by the way: stty -echo; command ;stty echo
You can hide the output of a comand in the following ways : echo -n "Installing nano......"; yum install nano > /dev/null; echo " done."; Redirect the standard output to /dev/null, but not the standard error. This will show the errors occurring during the installation, for example if yum cannot find a package.
''' indicates a multi line command. set +x turns off command echoing, and set -x turns it back on again. You can override this behaviour for the whole script by putting the following at the top of the build step: Can you mention how to add this line in groovy? like, sh (script:"#!/bin/bash +x"??
In general you can avoid console output from a Powershell cmdlet by piping its output to Out-Null. When you use external executables you should use Start-Processinstead of simply fire them. There you have the opportunity to redirect standard output and standard error to files you can specify. Best regards,
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
//commands to be echoed off
ls -al
set -x
'''
}
}
}
}
'''
indicates a multi line command. set +x
turns off command echoing, and set -x
turns it back on again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With