Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Git Plugin not pulling latest changes before building job

I am working with Jenkins CI and am trying to properly configure my jobs to use git.

I have the git plugin installed and configured for one of my jobs. When I build the job, I expect it to pull the latest changes for the branch I specify and then continue with the rest of the build process (e.g., unit tests, etc.).

When I look at the console output, I see

> git fetch --tags --progress ssh://gerrit@git-dev/Util +refs/heads/*:refs/remotes/origin/*  > git rev-parse origin/some_branch^{commit} Checking out Revision <latest_SHA1> (origin/some_branch)  > git config core.sparsecheckout  > git checkout -f <latest_SHA1>  > git rev-list <latest_SHA1> 

I see that the plugin fetches and checks out the proper commit hash, but when the tests run it seems as though the repo wasn't updated at all. If I go into the repository in Jenkins, I see there that the latest changes were never pulled.

Shouldn't it pull before it tries to build?

I have git 1.8.5 installed on my Jenkins machine, which is a recommended version. https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

After checking other similar sounding questions on SO, their answers weren't helpful for my problem.

like image 510
polarice Avatar asked Sep 10 '14 20:09

polarice


People also ask

How does Jenkins pull from git?

The Jenkins git plug-in 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 push changes to GitHub after Jenkins build completes?

1 Answer. There is an option - "Checkout to specific local branch" that can be found in the section - "Additional Behaviors" for setting the "Branch name" as master. Mind you, git commit -am "blah" is still necessary. Now you could use the 'Git Publisher' under the 'Post-build Actions' for pushing changes.

What is used to track the changes between builds in Jenkins?

The simplest way to know what has changed on your Jenkins builds! Last Changes is a Jenkin plugin that shows rich VCS diffs between builds.

Are git fetch and git pull the same?

git fetch is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn't do any file transferring. It's more like just checking to see if there are any changes available). git pull on the other hand does that AND brings (copy) those changes from the remote repository.


1 Answers

Relates me to scenario where workspace wasn't getting cleaned-up, used:

  • Source Code Management--> Additional Behaviours --> Clean after checkout enter image description here

  • Other option is to use Workspace Cleanup Plugin

like image 131
Abhijeet Avatar answered Sep 20 '22 02:09

Abhijeet