Jenkins Git Publisher: How to copy code back to master after build?

I'm having difficulty with Jenkins Git Publisher, committing and returning code back to the wizard after my build. My build process increases the version number in one of my files, and then I want to commit this file back to the repo, but I cannot get it to work.

In source control → Git, these are my settings:

  • Repository Name: Android
  • Branch Specification: Master
  • Checkout / merge to local branch: master

Then, in Git Publisher, these are my settings:

  • Click only if building a limit: checked
  • Combine results: checked
  • Commit for push: master
  • Target Name: Android
  • Notes: Note for push: Version Upgrade
  • Notes: Target Remote Name: Android
  • Notes: Namespace: Wizard

This is the result of Jenkins:

Pushing HEAD to branch master at repo Android Adding note to namespace "master": Updating version 

Please, help!

+6
source share
3 answers

I think jenkins git publisher plugin does nothing

 git add . git commit -m 'xxx' 

The plugin only does push and it is not necessary to add a note using git-notes .

Look here:

https://github.com/hamsterready/jenkins-git-publisher-test/tree/refs/notes/master

To achieve something like this: https://github.com/hamsterready/jenkins-git-publisher-test/commit/d80a1eef2133bee6d7a57b1b229ccd5990d2d606

I added a step after the build (execute shell script) with

 git add . git commit -m 'Updating git.properties' 

And then included git the publisher's post-build action, which moved the local commit to the beginning.

+4
source

If you also use Gradle for your collections, there is a Git plugin for it.

Here is the complete build.gradle :

 buildscript { repositories { mavenCentral() } dependencies { classpath "org.ajoberstar:gradle-git:0.6.3" } } import org.ajoberstar.gradle.git.tasks.* task tag(type: GitTag) { tagName = version message = "Release of $version" } task pushWithTags(type: GitPush){ credentials{ username = "karim" password = gitPassword } setPushTags(true) } task add(type: GitAdd){ include("yourVersionFile.txt") // or add everything with include("*") } task commit(type: GitCommit){ setMessage(commitMsg) } task pushNewVersion(){ tasks.add.execute() tasks.commit.execute() tasks.tag.execute() tasks.pushWithTags.execute() } 

This is how you add, put, commit and click using a script (there is a plugin to execute this from in Jenkins):

 gradle pushNewVersion "-PcommitMsg=hi" "-Pversion=0.1.1" "-PgitPassword=secret" 
+1
source

I had the same problem as returning the changes to their original state using the Jenkins Git plugin. What version of the Git client plugin are you using? There must be a bug in the Git client plugin and therefore the behavior.

They fixed the issue of re-clicking. Link: https://issues.jenkins-ci.org/browse/JENKINS-17242 . And it seems that it is broken, as there is one more error registered recently: https://issues.jenkins-ci.org/browse/JENKINS-19442

If you read the discussion in URLs, it is recommended that you use the fast Git client plugin to 1.0.5 and Git plugin to 1.3.0 solutions. Hope this works for you.

0
source

Source: https://habr.com/ru/post/949773/


All Articles