I am running my test cases though jenkins which are on my local branch. But jenkins is not taking the latest changes made on local. It runs with old code. Is there any way to get jenkins to run the latest code everytime? Attached are my settings of jenkins.
Asked
Active
Viewed 2,735 times
0
-
Yes, push the changes to where Jenkins is fetching it from. Or reconfigure Jenkins to fetch from your machine. – fredrik Nov 19 '19 at 07:58
-
How *could* it get the code from your local branch? Jenkins will get the code from the remote it's configured to access. – jonrsharpe Nov 19 '19 at 08:05
2 Answers
1
To use a Jenkins project properly, you need to configure the Source Code Management part using the repository url (this url is the one you use to clone your project, with git clone
).
If you don't have a remote repository, only with local directory (D:\test\automation
), you should set the repository url to file://D:\test\automation
as said in the selected answer of "Jenkins linking to my local git repository".
It is also important to configure the branches to build, in case you don't have only master
.
Then, if you want to run the builds automatically, you'll have to configure a trigger. It's often associated to remote repositories, since it seems you are using a local repository, I'll skip this step.
Then you can run manually a Jenkins job.

Paul Rey
- 1,270
- 1
- 15
- 26
-
Hi Paul, Thanks for responding butI was trying to pull the latest code in jenkins,so i tried wipe out and force clone in source code management in jenkins. I also changed the workspace to my local branch. But when i build it, it wipped out all my code. I dont have a back up . Is there any way to restore it? Also the history for these folder is not there so i can't recover the code from there too. Can you please help. – Tejashree Kutte Nov 19 '19 at 08:51
-
I think the way to do it is to configure Jenkins to clone your local repository in a different directory than your actual repository directory. This way Jenkins won't delete your source code each time it tries to run a job. I'm afraid it will be extremely hard to retrieve your deleted code. Do you still have your .git folder in your repo? – Paul Rey Nov 19 '19 at 09:04
-
-
Ouch... I don't know how you can retrieve your files. Did you have backups? Try this out: https://support.microsoft.com/en-us/help/17119/windows-7-recover-lost-deleted-files – Paul Rey Nov 19 '19 at 09:45
-
Hi Teja, Is your Jenkins is running in your laptop or some production server? – Anil Kumar Nov 19 '19 at 10:13
-
-
-
@PaulRey Hi Paul, i reconfigured the jenkins as you suggested, but it's still taking the old code. I mentioned the local branch which i am working on, but it shows the error which were there , but now they are fixed on my local. When i try to run it through visual code it works fine but it does not work on jenkins. – Tejashree Kutte Nov 19 '19 at 15:54
-
Jenkins started to take latest code when i changed the workspace to custom and gave the path of my local branch – Tejashree Kutte Nov 20 '19 at 06:27
-
Well, is it working now? Running jobs on local repository with a local Jenkins is uncommon. I suppose it's for testing before sending it on a production environment. But for now, I can't give you more advice than already said :( – Paul Rey Nov 20 '19 at 10:47
-
0
- Install the git plugin for Jenkins; I think its Manage Jenkins -> Manage plugins -> Git plugin.
- Once installed, in the project configuration, under source code management section, fill in the information like Repository URL, credentials, and the branch.
- Once the branch is selected, if you have made any commits, your next build should use the latest from that branch.

spinyBabbler
- 392
- 5
- 19