Jenkins Git Plugin not pulling latest changes before building job

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


I believe Jenkins pulls the changes and builds in it's own tmp directory. So, your repository directory isn't getting updated although Jenkins is properly building the new code in it's own sandbox.

My solution to this has been to add a "git pull" step in my build process like so:

When a new commit is delivered to my GitHub repo:
1. Build my project

If successful, perform the following post-build steps:
1. Execute Shell:

cd /your/repo/directory/
git pull

You can obviously modify the "git pull" command to do whatever you need to do if a 'pull' doesn't work for you.