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.
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.
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.
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.