Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push changes to github after jenkins build completes?

I have a jenkins job that clones the repository from github, then runs the powershell script that increments the version number in the file. I'm now trying to publish that update file back to the original repository on github, so when developer pulls the changes he gets the latest version number.

I tried using Git Publisher in the post build events, and I can publish tags with no issues, but it doesn't seem to publish any files.

like image 838
Woland Avatar asked Nov 12 '13 06:11

Woland


3 Answers

The git checkout master of the answer by Woland isn't needed. Instead use the "Checkout to specific local branch" in the "Additional Behaviors" section to set the "Branch name" to master.

The git commit -am "blah" is still needed.

Now you can use the "Git Publisher" under "Post-build Actions" to push the changes. Be sure to specify the "Branches" to push ("Branch to push" = master, "Target remote name" = origin).

"Merge Results" isn't needed.

like image 88
Claus Avatar answered Oct 02 '22 21:10

Claus


Found an answer myself, this blog helped: http://thingsyoudidntknowaboutjenkins.tumblr.com/post/23596855946/git-plugin-part-3

Basically need to execute:

git checkout master

before modifying any files

then

git commit -am "Updated version number"

after modified files

and then use post build action of Git Publisher with an option of Merge Results which will push changes to github on successful build.

like image 24
Woland Avatar answered Oct 02 '22 21:10

Woland


Actually, the "Checkout to specific local branch" from Claus's answer isn't needed as well.

You can just do changes, execute git commit -am "message" and then use "Git Publisher" with "Branch to push" = /refs/heads/master (or develop or whatever branch you need to push to), "Target remote name" = origin.

like image 10
Andrey Regentov Avatar answered Oct 02 '22 21:10

Andrey Regentov