Kohei Nozaki's blog 

Configuring automatic push by successfully build


Posted on Sunday Mar 01, 2015 at 11:19PM in Jenkins


Making Jenkins to push to an another remote repository if build finishes successfully.

Recipe

  1. Create a bare repository

    $ mkdir trader-stable.git
    $ cd trader-stable.git
    $ git init --bare
    Initialized empty Git repository in /Users/Shared/trader-stable.git/
    $
  2. Click Add Repository

    4a49f571 4135 43a8 915f e96db6eb902b
  3. Enter Repository URL

    e33f505c a52b 4752 83f9 44bf45b9db47
  4. Click Advanced…​

    507dc8b1 d86b 4cde b24c b59da15e84ed
  5. Enter stable to Name

    0f54d0a9 5317 40f5 9c60 ee13804a9904
  6. Click Add post-build actionGit Publisher

    44eeab12 4cf2 4c4a 81a9 785b99514659
  7. Check Push Only If Build Succeeds

  8. Click Add Tag

    60946cca e837 4245 a2c8 8e74c98c1f23
  9. Enter $BUILD_NUMBER to Tag to push

  10. Check Create new tag

  11. Enter stable to Target remote name

  12. Click Save

    2a9e7146 7663 414f 9499 91b65e028a43

Test

$ pwd
/Users/kyle/tmp/trader
$ echo 'push if succeeds test' >> hi.txt
$ git commit -am 'push if succeeds test'
$ git push origin master

Jenkins said Pushing tag 8 to repo stable

3e1e0e9a 2732 4054 8a20 82da0f67a7ab
$ git remote add stable /Users/Shared/trader-stable.git
$ git fetch stable
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (1/1), done.
From /Users/Shared/trader-stable
 * [new tag]         8          -> 8
$



Comments:

Good info! This is exactly what I needed as well. Does this push only tags or can it even push the whole repository? I tried several times and I see only tags on my second repository.

Posted by Srinivas on September 04, 2016 at 11:21 AM JST #


Hi,

What if my Tag name already exists and If I could see error like below.

> C:\Program Files (x86)\Git\bin\git.exe tag -l 9 # timeout=10
ERROR: Step ‘Git Publisher’ failed: Tag 9 already exists and Create Tag is specified, so failing.

Posted by Kalyan on January 31, 2017 at 02:27 PM JST #


So you are pushing to a local file system? Pushing to a remote server seems more helpful.

Posted by robert on April 15, 2017 at 06:32 AM JST #


Git publisher is not present in Jenkins v.2.176.1 or the git plugin v.3.10.1

Posted by Tom on July 10, 2019 at 10:19 PM JST #


Hi,

can you please help me to provide the process steps to publish the artifacts into GitHub server using Jenkins git publisher, Actually i am trying to push the artifacts into Azure local git not sure how to do it.
What would be the Target remote name? and where the git publisher will get the portal login details?

Posted by Madhu on November 12, 2019 at 02:48 PM JST #


Let See we are working on Multi pipeline project for CI-CD for one project we are using multiple repository.
Example : we have
1. one repository having data 'a' in A repository. its also store the Jenkins command.
2. second for some data 'b', store in B repository.
I am performing some addition between 'a' (A) and 'b' (B) let se output is 'c' .
now I wanted to push the expected output 'c' to the different repository C.

In (C) repository I already have some data. I don't want to create bare repository.

the error i was facing is
/jenkins/workspace/A@tmp/durable-ssasd/script.sh: 5: /jenkins/workspace/A@tmp/durable-ssasd/script.sh: git: not found

Posted by SANJEEV PRAJAPATI on January 13, 2020 at 04:43 PM JST #


Leave a Comment

HTML Syntax: NOT allowed