Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28335

Step to run Git commands w/ credentials & tool (was: GitPublisher support)

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      It would be nice to be able to use the GitPublisher inside a workflow as it is possible in other jobs.

      This requires the plugin to be upgrade to Jenkins core 1.580.1+, to implement the jenkins.tasks.SimpleBuildStep in GitPublisher

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            As already noted in this issue, you can already use withCredentials or sshagent to accomplish this use case. This enhancement would simply make it more convenient.

            Show
            jglick Jesse Glick added a comment - As already noted in this issue, you can already use withCredentials or sshagent to accomplish this use case. This enhancement would simply make it more convenient.
            Hide
            zeninr Ruslan Zenin added a comment - - edited

            Hi Jesse Glick . would it be possible to provide a sample pipeline script how we can accomplish "git push withCredentials or sshagent"? There is a use case for my team to build projects and change some of the artifacts and then push back to the SCM.
            Thank you in advance!
            Note: I found this example: https://jenkins.io/doc/pipeline/examples/#push-git-repo

            withCredentials([usernamePassword(credentialsId: 'git-pass-credentials-ID', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { sh("git tag -a some_tag -m 'Jenkins'") sh('git push https://${GIT_USERNAME}:${GIT_PASSWORD}@<REPO> --tags') }

            Show
            zeninr Ruslan Zenin added a comment - - edited Hi Jesse Glick  . would it be possible to provide a sample pipeline script how we can accomplish "git push withCredentials or sshagent" ? There is a use case for my team to build projects and change some of the artifacts and then push back to the SCM. Thank you in advance! Note: I found this example: https://jenkins.io/doc/pipeline/examples/#push-git-repo withCredentials( [usernamePassword(credentialsId: 'git-pass-credentials-ID', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')] ) { sh("git tag -a some_tag -m 'Jenkins'") sh('git push https://$ {GIT_USERNAME}:${GIT_PASSWORD}@<REPO> --tags') }
            Hide
            kodstark Kamil Demecki added a comment -

            Ruslan Zenin Above there are examples working for me with ssh key. I didn't check how to use credentials with password if you are asking about this case specific.

            sshagent(['credentiald-id-using-ssh-key']) 
             {
                sh('git command or program calling git inside') 
             }
            
            Show
            kodstark Kamil Demecki added a comment - Ruslan Zenin Above there are examples working for me with ssh key. I didn't check how to use credentials with password if you are asking about this case specific. sshagent([ 'credentiald-id-using-ssh-key' ]) {     sh( 'git command or program calling git inside' ) }
            Hide
            zeninr Ruslan Zenin added a comment - - edited

            Kamil Demecki Thank you! That worked for me!

            Show
            zeninr Ruslan Zenin added a comment - - edited Kamil Demecki Thank you! That worked for me!
            Hide
            drdamour chirs damour added a comment - - edited

            we had been using the sshagent workaround, but recently changed to using the "Checkout over SSH" git scm custom behaviour.  This made the sshagent wrapper unecessary in the scripts (i'm guessing cause it basically wraps your whole pipeline as such..kind of). Not sure how portable this is to windows or non git environments but was easier for us.

            Also to control the commit/author email was used the Custom user name/e-mail address custom behaviour

            Show
            drdamour chirs damour added a comment - - edited we had been using the sshagent workaround, but recently changed to using the "Checkout over SSH" git scm custom behaviour.  This made the sshagent wrapper unecessary in the scripts (i'm guessing cause it basically wraps your whole pipeline as such..kind of). Not sure how portable this is to windows or non git environments but was easier for us. Also to control the commit/author email was used the  Custom user name/e-mail address  custom behaviour

              People

              • Assignee:
                Unassigned
                Reporter:
                alecharp Adrien Lecharpentier
              • Votes:
                123 Vote for this issue
                Watchers:
                133 Start watching this issue

                Dates

                • Created:
                  Updated: