How to push changes to github after jenkins build completes?

前端 未结 4 1623
有刺的猬
有刺的猬 2020-12-05 02:00

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

相关标签:
4条回答
  • 2020-12-05 02:09

    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.

    0 讨论(0)
  • 2020-12-05 02:09

    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.

    0 讨论(0)
  • 2020-12-05 02:12

    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.

    0 讨论(0)
  • 2020-12-05 02:18

    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.

    0 讨论(0)
提交回复
热议问题