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
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.
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.
I followed the below Steps. It worked for me.
In Jenkins execute shell under Build, creating a file and trying to push that file from Jenkins workspace to GitHub.
Download Git Publisher Plugin and Configure as shown below snapshot.
Click on Save and Build. Now you can check your git repository whether the file was pushed successfully or not.
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.