1

using a minimal jenkinsfile as an example

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

blue ocean logs

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.

2
  • The screenshot does not seem to match your code. It has set +x. Do you have a screenshot of the code you shared? – ssc327 Jun 19 at 15:10
  • Can you also show a screenshot with the step expanded (click that arrow) – ssc327 Jun 19 at 15:11
1
  1. 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

  2. If you want to capture the output do. def msg = sh(returnStdout: false, script: "echo 'this should not be logged it is secret'")

  3. 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
      }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.