Tagging code in a pipeline?

24 views
Skip to first unread message

Robert Nicholson

unread,
Mar 21, 2019, 2:51:42 PM3/21/19
to jenkins...@googlegroups.com
I am able to tag the code locally but the push with credentials key based seems to be an issue.

sshagent([‘credentialsKey]) {
sh “git push origin master —tags”
}

this step errors with

fatal: could not read Username for ‘repository hostname’ : No such device or address

Prior in my pipeline I have a repository defined using

Pipeline script from SCM where the url is defined with https://……..git

What is the recommended approach to push when using primary/public key with git from JenkinsFile pipeline?

Mark Waite

unread,
Mar 21, 2019, 2:56:29 PM3/21/19
to Jenkins Users
Is the repository URL an ssh URL?  If not, then sshagent won't help.  The ssh agent does not do http or https

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/D357517D-5BB0-4A3B-9409-F025C01D470B%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

Robert Nicholson

unread,
Mar 22, 2019, 10:00:47 AM3/22/19
to jenkins...@googlegroups.com
Ok it’s a https: url

So how do you construct the appropriate 

ssh command then?

all examples that use withCredentials seems to fail on my side.



Mark Waite

unread,
Mar 22, 2019, 10:24:27 AM3/22/19
to Jenkins Users
Most git repository providers (GitHub, Bitbucket, Gitlab, Visual Studio, Gitea, Assembla, Beanstalk,etc.) provide a small UI component that will allow you to toggle between the https URL to the repository and the ssh URL to the repository.

For example, the GitHub box looks like this:

image.png

If your remote repository does not allow ssh access, then it becomes much more complicated, though it is probably still possible.

Mark Waite


For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

Ivan Fernandez Calvo

unread,
Mar 22, 2019, 1:13:26 PM3/22/19
to Jenkins Users
for the https case, there is an example at https://jenkins.io/doc/pipeline/examples/#push-git-repo

Robert Nicholson

unread,
Mar 22, 2019, 7:11:19 PM3/22/19
to jenkins...@googlegroups.com
I haven’t tried any ssh: url based approach yet.

but the approaches I’ve seen are when you use GIT_SSH etc to inject your own private key into the ssh that was
extracted using withCredentials and written to a tmp folder on disk temporarily but I see no indication that it’s
ever using this key.

Rade Milijasevic

unread,
Mar 23, 2019, 1:20:27 PM3/23/19
to jenkins...@googlegroups.com
Can somebody please give an example code for both https:// url and ssh approach.
thanks 

Mark Waite

unread,
Mar 23, 2019, 1:21:30 PM3/23/19
to Jenkins Users
https://jenkins.io/doc/pipeline/examples/#push-git-repo provides examples of ssh and https.

Mark Waite

Mark Waite

unread,
Mar 23, 2019, 1:24:29 PM3/23/19
to Jenkins Users
https://jenkins.io/doc/pipeline/examples/#push-git-repo gives an example of both https and ssh


On Saturday, March 23, 2019 at 11:20:27 AM UTC-6, Rade Milijasevic wrote:
Can somebody please give an example code for both https:// url and ssh approach.
thanks 

On Fri, Mar 22, 2019 at 5:11 PM Robert Nicholson  wrote:
I haven’t tried any ssh: url based approach yet.

but the approaches I’ve seen are when you use GIT_SSH etc to inject your own private key into the ssh that was
extracted using withCredentials and written to a tmp folder on disk temporarily but I see no indication that it’s
ever using this key.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
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 jenkinsci-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages