How to hide the checkout scm step output in console output of Jenkins

Viewed 3009

My first stage in Jenkinsfile(scripted pipeline) is checkout scm, which gives a brief description about the GitHub checkouts and all revision related things which I don't want to display in Jenkins console output.

Is it possible to hide this in console output of Jenkins. following console output is from Jenkins for checkout scm step, which I want to hide

Cloning the remote Git repository
Cloning repository https://github.com/forpi/cherry-pik.git
 > git init /home/ubuntu/.jenkins/workspace/Dummy-project # timeout=10
Fetching upstream changes from https://github.com/forpi/cherry-pik.git
 > git --version # timeout=10
 > git fetch --tags --progress https://github.com/forpi/cherry-pik.git +refs/heads/*:refs/remotes/origin/*
 > git config remote.origin.url https://github.com/forpi/cherry-pik.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url https://github.com/forpi/cherry-pik.git # timeout=10
Fetching upstream changes from https://github.com/forpi/cherry-pik.git
 > git fetch --tags --progress https://github.com/forpi/cherry-pik.git +refs/heads/*:refs/remotes/origin/*

 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision b80c4d6b655429d7f84347b4192461cc3d68283e (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f b80c4d6b69c429d7f84347b4192461cc3d68283e
 > git branch -a -v --no-abbrev # timeout=10
 > git checkout -b master b80c4d6b655429d7f84347b4192461cc3d68283e
Commit message: "lets try this again" 
2 Answers

Checkout scm has option to provide arguments like this and there is a quietoperation mode availabe

checkout([$class: 'SubversionSCM', 
        additionalCredentials: [], 
       locations: [[cancelProcessOnExternalsFail: true, 
        credentialsId: '234243-45654-234randomstuff', 
        depthOption: 'infinity', 
        ignoreExternalsOption: true, 
        local: '.', 
        remote: 'https://starkindustries/ironman/superGlueForThanosFingers/repo']],
        **quietOperation: true,** 
        workspaceUpdater: [$class: 'UpdateUpdater']])

You can also try this

checkout scm &> /dev/null

This will suppress stdout and stderr, unless the git command fails

or

If you want to checkout using git

git checkout origin master --quiet
git checkout origin master --q

Which is an available option in git.

Hope it helps :)

Related