Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing tags with Jenkins Git Publisher - multiple Git repositories (forks)

Our team is transitioning from CVS to Git. We intend to use the similar workflow as most open source projects on GitHub - each developer takes a fork of the main repo and then submits a pull request which will allow the project master to do a code review before merging the changes into the main repo.

Jenkins allows us to add multiple Git repositories (the standard Git plugin, not the Multiple SCM one). Presumably I can enter the URL for each forked repo and then Jenkins will check all branches each fork for changes. I give each repository a name eg "master", "developer1", "developer2"...

We want to have Jenkins tagging each build on the appropriate remote/fork. The Git Publisher plugin requires that you provide the "target remote name", but we need Jenkins to be able to figure this out for itself.

like image 864
Nicholas Albion Avatar asked Sep 06 '13 05:09

Nicholas Albion


People also ask

How do I push all tags in GitHub?

This process is just like sharing remote branches — you can run git push origin <tagname> . If you have a lot of tags that you want to push up at once, you can also use the --tags option to the git push command. This will transfer all of your tags to the remote server that are not already there.

Does git push push all tags?

By default, git push will not push tags. Tags have to be explicitly passed to git push . To push multiple tags simultaneously pass the --tags option to git push command.

Can Jenkins push to git?

The git plugin provides fundamental git operations for Jenkins projects. It can poll, fetch, checkout, branch, list, merge, tag, and push repositories.


1 Answers

I've managed to solve this one myself.

  • At the top of the Jenkins project config page check "This build is parameterized" and add a string parameter "remote" with default "master".
  • Add "Git Publisher" as a Post-build action, and a Tag "$BUILD_TAG" and Target remote name = "$remote"
  • In Build Triggers, check "Trigger builds remotely"
  • We're using GitLab and under the project Settings menu I add a "Web Hook":

    http://my-jenkins-server.com/job/my-project/buildWithParameters?token=secret&remote=master

Add a web hook for each fork, and make sure that the "remote" parameter matches the repository name configured in Jenkins.

like image 149
Nicholas Albion Avatar answered Oct 21 '22 03:10

Nicholas Albion