'Jenkins pipeline: How to checkout repository without triggering polling or tracking changes?
My project consists of multiple git repositories. One main repository, and other helper repositories. In jenkins pipeline, I want to checkout scm:
all of them, but I am only interested in tracking changes, and polling from the main repository - others clutter the changelog and cause other infrastructure problems (it's a big project).
I thought about simply checking out remaining repositories in sh
blocks to skip "features" I don't want, but I'll have to duplicate config, and somehow pass credentials - generally I'd like pipelines to do the work for me.
Expected result:
checkout scm
does not cause changelog to appear, or cause polling from said repo down the line.
Is there a way to archive this using configuration, instead of hiding checkout logic from pipeline using sh
step?
Solution 1:[1]
When you checkout the other repositories, you can disable the changelog and polling with the optional arguments to the class. For example, given a helper repository called helper
:
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
userRemoteConfigs: [[url: 'http://git-server/user/helper.git']]
changelog: false,
poll: false
])
and then the changelog and polling will be disabled for the helper
repository. You can duplicate this usage for all your other helper repositories to disable their changelog and polling.
Check the GitSCM Pipeline Step documentation for more information.
Solution 2:[2]
Use the following code in Jenkinsfile:
checkout scm: scm, poll: false, changelog: false
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Matt Schuchard |
Solution 2 | pablo285 |