patternMinor
Blue ocean logging my step commands
Viewed 0 times
loggingcommandsbluestepocean
Problem
using a minimal jenkinsfile as an example
For some reason the following occurs
I'm not sure what's going on here. Ideally I want the cmand not to be displayed and the label to take the place of the command.
node("master") {
stage("Test") {
sh(
label: "THIS SHOULD DISPLAY",
script: "set -e; echo 'this should not be logged it is secret'"
)
}
}For some reason the following occurs
I'm not sure what's going on here. Ideally I want the cmand not to be displayed and the label to take the place of the command.
Solution
-
If you run a script you have to specify where the output goes.
sh(returnStdout: true, script: "echo 'this should not be logged it is secret'")
returnStdout: true is standard, set it to false and nothing is shown
-
If you want to capture the output do.
def msg = sh(returnStdout: false, script: "echo 'this should not be logged it is secret'")
-
label: "THIS SHOULD DISPLAY" puts a Label on the "sup"step to display on the Jenkins site. What you see is the intended result.
conclusion:
If you run a script you have to specify where the output goes.
sh(returnStdout: true, script: "echo 'this should not be logged it is secret'")
returnStdout: true is standard, set it to false and nothing is shown
-
If you want to capture the output do.
def msg = sh(returnStdout: false, script: "echo 'this should not be logged it is secret'")
-
label: "THIS SHOULD DISPLAY" puts a Label on the "sup"step to display on the Jenkins site. What you see is the intended result.
conclusion:
node("master") {
stage("Test") {
script {
def msg = sh(
returnStdout: false,
label: "THIS SHOULD DISPLAY",
script: "set -e; echo 'this should not be logged it is secret'"
)
// do whatever you want with the output msg
}
}
}Code Snippets
node("master") {
stage("Test") {
script {
def msg = sh(
returnStdout: false,
label: "THIS SHOULD DISPLAY",
script: "set -e; echo 'this should not be logged it is secret'"
)
// do whatever you want with the output msg
}
}
}Context
StackExchange DevOps Q#14133, answer score: 1
Revisions (0)
No revisions yet.