Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide command executed, only show output

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

like image 959
Binh Pham Avatar asked Nov 28 '17 04:11

Binh Pham


People also ask

How do I hide the output of a program in Linux?

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

How to hide the output of a Yum COMAND?

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.

What does the command ''''' mean in bash script?

''' 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"??

How to disable console output from a PowerShell cmdlet?

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,


1 Answers

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.

like image 50
Ben Green Avatar answered Oct 18 '22 05:10

Ben Green