There isn't a straight-forward way to define a pipeline job such that you can perform arbitrary git commands using a credential.
That seems like it would require one or more extensions to the git plugin. The alternatives described in the stackoverflow article can be used, each with their own strengths and weaknesses. None of them are elegant enough to be called "straight-forward". Mark Waite On Wed, Nov 30, 2016 at 7:39 AM Torsten Reinhard <[email protected]> wrote: > See also > http://stackoverflow.com/questions/39237910/jenkins-pipeline-cannot-check-code-into-git > - but there“s no real answer, just workarounds using ssh-agent - or a > different protocol with user/password. > > So still the question: Any idea how to setup this in a straight-forward > manner ? > > > Am Mittwoch, 30. November 2016 12:20:22 UTC+1 schrieb Torsten Reinhard: > > Hi all, > > I have a Multi Branch Project, using a *.git Repository. All branches are > detected and the checkout is working. > In my JenkinsFile I need to execute some "git" commands, like: > > ... > sh "git tag -d FOR_INTEGRATION_TESTING" // removes > the tag in local env. > sh "git push origin :refs/tags/FOR_INTEGRATION_TESTING" // removes > the tag in remote env. > sh "git tag -a FOR_INTEGRATION_TESTING" // adds > the tag to different commit > sh "git push origin FOR_INTEGRATION_TESTING" // pushes the > change to the remote > ... > > How can I apply the credentials here ? > When trying > > withCredentials [$class: 'UsernamePasswordMultiBinding', credentialsId: > git_creds, usernameVariable: 'G_USER', passwordVariable: 'G_PASS'] { > ... > } > > > I see this exception: > > org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: > Credentials 'a378e16a-3d20-4465-aef1-b2bd233f15b6' is of type 'SSH Username > with private key' > where > 'com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials' > was expected > > > Is there another class instead of "UsernamePasswordMultiBinding" I have to > use? > > Thanx for pointing me in the right direction, > > Torsten > > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/493ec847-06ac-486d-befb-26c9d9496b92%40googlegroups.com > <https://groups.google.com/d/msgid/jenkinsci-users/493ec847-06ac-486d-befb-26c9d9496b92%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtGZRSfNX2JOnkC%3DRuph9bkJ9eVwosx5-PC2cX%3DPc7abVw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
