Is there an option to monitor a git repository in Jenkins, but not do the pull/clone/fetch upon commit?
I want the triggering of a build job based upon a commit to the specified branch in the repository, but I don't want the Jenkins build job to do the automatic pull/clone/fetch.
The key to Jenkins Git integration is the Git plug-in. One can easily install the Jenkins Git plug-in through the Jenkins administrative console, and once properly configured, it gives all Jenkins build jobs the option to pull content from a Git-compatible source code repository.
Step 1: go to your GitHub repository and click on 'Settings'. Step 2: Click on Webhooks and then click on 'Add webhook'. Step 3: In the 'Payload URL' field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/.
There are two ways to clone the project(repository) from Github. Create a new Jenkins job called 'Clone-with-https', move to the “Source Control Management” setting, and choose “Git” options if you cannot see the Git options that mean the 'GitHub' plugin wasn't installed in the Jenkins machine.
Apparently, there is no way to poll a github repository to start a Jenkins task and not download the aforementioned github repository.
While there is no way to poll a github repository to kick off a job without first pulling in the code for that job, you can work around this problem by using the jenkins multijob plugin to set up a multi phase job, configured as follows:
WORKSPACE-A
. This job will
poll the git repo you are monitoring. When a change is made, the job
will pull the changes (which you won't use) and then proceed with the build, whose steps will be to kick off two other jobs in series.WORKSPACE-B
and it tracks no git
repository. This job can do any of the pre-configuration you want.
Because it exists in a workspace different from that of the master
job, it will not be polluted by the source code from git.WORKSPACE-A
or WORKSPACE-B
if that's what you want. You can
either have this job track the same repo as the master job so that
the changes are automatically pulled into the workspace, or copy the
files already cloned from your git repo from WORKSPACE-A
into this job's
workspace.Note: Only the master job should have a build trigger -- the one tied to changes to the git repo. The other two jobs will be triggered externally from the master job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With