Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitor a repository in Jenkins, but don't pull

Is there an option to monitor a git repository in Jenkins, but not do the pull/clone/fetch upon commit?

  • The Source Code Mangement set to "Git"
  • The Repository URL is set to [email protected]:name/branch.git
  • The Branch to build is set to origin/1.0

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.

like image 457
user2569618 Avatar asked Mar 25 '15 18:03

user2569618


People also ask

How do I pull in Jenkins?

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.

How do I link my Git repository to Jenkins?

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/.

How does Jenkins clone repository?

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.


2 Answers

Apparently, there is no way to poll a github repository to start a Jenkins task and not download the aforementioned github repository.

like image 93
user2569618 Avatar answered Oct 02 '22 03:10

user2569618


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:

  • Configure a master job that resides in 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.
  • Configure a second job to be triggered as the first build phase by the master job. This job will reside in 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.
  • Configure a third job to be triggered as the second and final build phase by the master job. This job may reside anywhere you need it to -- including 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.

like image 44
Clandestine Avatar answered Oct 02 '22 03:10

Clandestine