• git plugin 4.8.0

      Currently the GIT Plugin only allows to create pre-defined tags, but not to push all tags created during a build.

          [JENKINS-25389] Allow push of tags created during the build

          David Van Gompel added a comment - - edited

          For anyone who's interested, I've found a workaround:

          1. Add something like this to your shell script:

          #!/bin/sh
          APP_BUILD_NUMBER=`npm version patch`
          echo APP_BUILD_NUMBER=${APP_BUILD_NUMBER} > build.properties
          

          2. then add build step Inject environment variables and set Properties File Path to `$WORKSPACE/build.properties`

          3. after that, $APP_BUILD_NUMBER is accessible in all build steps as environment variable. Click `Add tag` in Git Publisher (Post-build action) and set tag to push to $APP_BUILD_NUMBER.

          David Van Gompel added a comment - - edited For anyone who's interested, I've found a workaround: 1. Add something like this to your shell script: #!/bin/sh APP_BUILD_NUMBER=`npm version patch` echo APP_BUILD_NUMBER=${APP_BUILD_NUMBER} > build.properties 2. then add build step Inject environment variables and set Properties File Path to `$WORKSPACE/build.properties` 3. after that, $APP_BUILD_NUMBER is accessible in all build steps as environment variable. Click `Add tag` in Git Publisher (Post-build action) and set tag to push to $APP_BUILD_NUMBER.

          Jon Has added a comment -

          It was sure easier if this feature would exist.

          Using the jgitflow:release-start/finish creates a tag in the build process, but doesn't push it to remote git.

          This feature would make it easier instead of configuring git ssh with the jenkins machine + manually call git commands (because git commands requires password, which cannot be done in an automatic job)

          Jon Has added a comment - It was sure easier if this feature would exist. Using the jgitflow:release-start/finish creates a tag in the build process, but doesn't push it to remote git. This feature would make it easier instead of configuring git ssh with the jenkins machine + manually call git commands (because git commands requires password, which cannot be done in an automatic job)

          Kevin Lannen added a comment -

          This should be a simple call to `git push <remote-name> --tags` Why is this still an open issue 3 years after it was reported? I'm using zest releaser for python and it adds tags to commits it creates but there's no way to push these tags up that I can find.

          Kevin Lannen added a comment - This should be a simple call to `git push <remote-name> --tags` Why is this still an open issue 3 years after it was reported? I'm using zest releaser for python and it adds tags to commits it creates but there's no way to push these tags up that I can find.

          Mark Waite added a comment -

          The git plugin has implemented a git credentials binding in git plugin 4.8.0. The git credentials binding allows a Pipeline step (sh, bat, or powershell) or a freestyle project build step (shell, batch, powershell, XShell) to perform authenticated git operations.

          See the blog post, the git plugin Pipeline documentation, and the git plugin freestyle project documentation.

          Won't be implemented in the git publisher because it can now be done with the more general purpose git credentials binding.

          Mark Waite added a comment - The git plugin has implemented a git credentials binding in git plugin 4.8.0. The git credentials binding allows a Pipeline step (sh, bat, or powershell) or a freestyle project build step (shell, batch, powershell, XShell) to perform authenticated git operations. See the blog post , the git plugin Pipeline documentation , and the git plugin freestyle project documentation . Won't be implemented in the git publisher because it can now be done with the more general purpose git credentials binding.

          Hello,

          I use freestyle jobs but I access git via SSH.
          How can I do that with the bindings?

          Réda Housni Alaoui added a comment - Hello, I use freestyle jobs but I access git via SSH. How can I do that with the bindings?

          Mark Waite added a comment - - edited

          The GSoC project is currently developing the ssh private key binding to match the username / password binding. We expect to be complete in the next 4-6 weeks. If you'd like to assist with the testing, you're welcome to work with us on PR-1111. You could experiment with the current pre-release build of that pull request to see if it already addresses your need.

          Alternately, you could add a username / password credential to your Jenkins job and configure it to push through the https interface using the username / password credential

          Mark Waite added a comment - - edited The GSoC project is currently developing the ssh private key binding to match the username / password binding. We expect to be complete in the next 4-6 weeks. If you'd like to assist with the testing, you're welcome to work with us on PR-1111 . You could experiment with the current pre-release build of that pull request to see if it already addresses your need. Alternately, you could add a username / password credential to your Jenkins job and configure it to push through the https interface using the username / password credential

          Réda Housni Alaoui added a comment - - edited

          We have been dealing with this issue for years.

          Our workaround has been to have a post build step in the form of the following shell script:

          git pull origin master
          git push origin master --tags

          But with this, we depend on the private key of the machine running the job. It does not scale well with multiple agents.

          Even with the added git ssh private key binding, I don't see how this will allow my shell script to keep working as is. I sense that I am gonna need to tweak it some way. If that is the case, the script will probably stop being portable across Linux/Windows.

          If I can keep my shell as is, that should be ok. If I could drop the shell for something more framed, that would be a lot better.

          Réda Housni Alaoui added a comment - - edited We have been dealing with this issue for years. Our workaround has been to have a post build step in the form of the following shell script: git pull origin master git push origin master --tags But with this, we depend on the private key of the machine running the job. It does not scale well with multiple agents. Even with the added git ssh private key binding, I don't see how this will allow my shell script to keep working as is. I sense that I am gonna need to tweak it some way. If that is the case, the script will probably stop being portable across Linux/Windows. If I can keep my shell as is, that should be ok. If I could drop the shell for something more framed, that would be a lot better.

          Mark Waite added a comment -

          One of the freestyle projects that I used for my testing was configured to push tags. I even used the XShell plugin so that I could run the same freestyle project on Windows and on Linux. In that case, the command I used was

          git push --tags
          

          That command works in both batch and in shell and keeps the freestyle project simple.

          The freestyle usage is described at https://plugins.jenkins.io/git/#git-bindings. It makes the credential available to all the build steps in the freestyle project. I placed my "git push" in an xshell build step that was the last build step of the job.

          Mark Waite added a comment - One of the freestyle projects that I used for my testing was configured to push tags. I even used the XShell plugin so that I could run the same freestyle project on Windows and on Linux. In that case, the command I used was git push --tags That command works in both batch and in shell and keeps the freestyle project simple. The freestyle usage is described at https://plugins.jenkins.io/git/#git-bindings . It makes the credential available to all the build steps in the freestyle project. I placed my "git push" in an xshell build step that was the last build step of the job.

          I suppose the example you are talking about was using git username/password binding.

          I suppose it will work the same once https://ci.jenkins.io/job/Plugins/job/git-plugin/view/change-requests/job/PR-1111/ is merged?

          Réda Housni Alaoui added a comment - I suppose the example you are talking about was using git username/password binding. I suppose it will work the same once https://ci.jenkins.io/job/Plugins/job/git-plugin/view/change-requests/job/PR-1111/  is merged?

          Réda Housni Alaoui added a comment - - edited

          Since https://ci.jenkins.io/job/Plugins/job/git-plugin/view/change-requests/job/PR-1111/ is not ready yet, https://github.com/jenkinsci/git-plugin/pull/1126 was rejected and some people may prefer a simple UI to a shell script, I just published https://github.com/jenkinsci/git-push-plugin/ .

          https://github.com/jenkinsci/git-push-plugin/ precisely fullfill the need described in this ticket, which is pushing (using the configured scm git credentials) all tags (and commits) created by the build (be it npm, yarn, maven, ...) without knowing their names before the build begins.

          Réda Housni Alaoui added a comment - - edited Since https://ci.jenkins.io/job/Plugins/job/git-plugin/view/change-requests/job/PR-1111/  is not ready yet, https://github.com/jenkinsci/git-plugin/pull/1126  was rejected and some people may prefer a simple UI to a shell script, I just published https://github.com/jenkinsci/git-push-plugin/  . https://github.com/jenkinsci/git-push-plugin/ precisely fullfill the need described in this ticket, which is pushing (using the configured scm git credentials) all tags (and commits) created by the build (be it npm, yarn, maven, ...) without knowing their names before the build begins.

            Unassigned Unassigned
            mario_mancino Mario Mancino
            Votes:
            9 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: