如何在Jenkins的控制台输出中隐藏checkout scm step输出

时间:2018-08-31 02:24:31

标签: jenkins github devops

我在Jenkinsfile(脚本化管道)中的第一阶段是checkout scm,它简要介绍了GitHub Checkout和所有与修订有关的内容,我不想在Jenkins控制台输出中显示

是否可以将其隐藏在Jenkins的控制台输出中。 以下控制台输出来自Jenkins,用于我想隐藏的scm步骤

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 个答案:

答案 0 :(得分:0)

试试这个方便的插件: https://wiki.jenkins.io/display/JENKINS/Collapsing+Console+Sections+Plugin

它可能不是很整洁,但是可以完成工作。

答案 1 :(得分:0)

Checkout scm可以选择提供这样的参数,并且有一个安静的操作模式

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']])

您也可以尝试

checkout scm &> /dev/null

除非git命令失败,否则这将禁止stdout和stderr

如果要使用git结帐

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

哪个是git中可用的选项。

希望它会有所帮助:)