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

17,424

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.

Share:
17,424

Related videos on Youtube

Nicholas Albion
Author by

Nicholas Albion

Updated on September 16, 2022

Comments

  • Nicholas Albion
    Nicholas Albion over 1 year

    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.