GitHub Clone to Different Local Directory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

GitHub Clone to Different Local Directory

Eric Fetzer
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Mark Waite-2
If you're using pipeline, change to that directory with the dir('/users/username/projectname') { } wrapper around the checkout step;

If you're using a freestyle job, use the git plugin extension 'checkout to a subdirectory'

On Fri, Mar 26, 2021 at 10:54 AM [hidden email] <[hidden email]> wrote:
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG6VTjt8F7Vj5pJW13VQJTfxCqRuZuDHjj5zZTa3jJ9%3Dg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Thanks for the response Mark..  I'm using freestyle.  Doesn't checkout to a subdirectory only take relative paths?



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 6:44 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

If you're using pipeline, change to that directory with the dir('/users/username/projectname') { } wrapper around the checkout step;

If you're using a freestyle job, use the git plugin extension 'checkout to a subdirectory'

On Fri, Mar 26, 2021 at 10:54 AM [hidden email] <[hidden email]> wrote:
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG6VTjt8F7Vj5pJW13VQJTfxCqRuZuDHjj5zZTa3jJ9%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/605e9199.1c69fb81.932c2.d78c%40mx.google.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Mark Waite-2
Good point.  How about the external workspace plugin from GSoC 2016?  https://plugins.jenkins.io/external-workspace-manager/

On Fri, Mar 26, 2021 at 8:00 PM eric.fetzer <[hidden email]> wrote:
Thanks for the response Mark..  I'm using freestyle.  Doesn't checkout to a subdirectory only take relative paths?



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 6:44 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

If you're using pipeline, change to that directory with the dir('/users/username/projectname') { } wrapper around the checkout step;

If you're using a freestyle job, use the git plugin extension 'checkout to a subdirectory'

On Fri, Mar 26, 2021 at 10:54 AM [hidden email] <[hidden email]> wrote:
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG6VTjt8F7Vj5pJW13VQJTfxCqRuZuDHjj5zZTa3jJ9%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/605e9199.1c69fb81.932c2.d78c%40mx.google.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHWfuOvLQubF%2BWHBoExHugTGd_FnmEvh2fHWPMNcH08ZQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Thanks Mark, I'll check it out.  Has to beat the hokey workaround I worked up.  :)



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 10:49 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

Good point.  How about the external workspace plugin from GSoC 2016?  https://plugins.jenkins.io/external-workspace-manager/

On Fri, Mar 26, 2021 at 8:00 PM eric.fetzer <[hidden email]> wrote:
Thanks for the response Mark..  I'm using freestyle.  Doesn't checkout to a subdirectory only take relative paths?



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 6:44 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

If you're using pipeline, change to that directory with the dir('/users/username/projectname') { } wrapper around the checkout step;

If you're using a freestyle job, use the git plugin extension 'checkout to a subdirectory'

On Fri, Mar 26, 2021 at 10:54 AM [hidden email] <[hidden email]> wrote:
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG6VTjt8F7Vj5pJW13VQJTfxCqRuZuDHjj5zZTa3jJ9%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/605e9199.1c69fb81.932c2.d78c%40mx.google.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHWfuOvLQubF%2BWHBoExHugTGd_FnmEvh2fHWPMNcH08ZQ%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/605ea0fc.1c69fb81.fb3e3.5cbf%40mx.google.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Björn Pedersen
Did you try to use credentials in jenkins to store the token  instead of  fiddling  with token on the machine?
See e.g. https://stackoverflow.com/questions/61105368/how-to-use-github-personal-access-token-in-jenkins


Then you could do everything in one job instead of  doing some copy-magic (which would  horribly break once you start to use more nodes).

Björn
[hidden email] schrieb am Samstag, 27. März 2021 um 04:05:44 UTC+1:
Thanks Mark, I'll check it out.  Has to beat the hokey workaround I worked up.  :)



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 10:49 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

Good point.  How about the external workspace plugin from GSoC 2016?  https://plugins.jenkins.io/external-workspace-manager/

On Fri, Mar 26, 2021 at 8:00 PM eric.fetzer <[hidden email]> wrote:
Thanks for the response Mark..  I'm using freestyle.  Doesn't checkout to a subdirectory only take relative paths?



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 6:44 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

If you're using pipeline, change to that directory with the dir('/users/username/projectname') { } wrapper around the checkout step;

If you're using a freestyle job, use the git plugin extension 'checkout to a subdirectory'

On Fri, Mar 26, 2021 at 10:54 AM [hidden email] <[hidden email]> wrote:
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG6VTjt8F7Vj5pJW13VQJTfxCqRuZuDHjj5zZTa3jJ9%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/605e9199.1c69fb81.932c2.d78c%40mx.google.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6fbec4af-2389-44fb-85fd-2c745572f548n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Yes Bjorn, that's the thread I used to figure out how to use the access token.  Unfortunately, the jenkins plugin isn't smart enough to pass a username, it uses the username it runs as.  So my master node is running as the user "jenkins" so it tries to authenticate to GitHub Enterprise as jenkins:<myToken which of course fails.  So I created a different node to run as my user, which thankfully, is the same username as I have in GitHub Enterprise.  Smoke and mirrors...

On Monday, March 29, 2021 at 3:26:47 AM UTC-6 [hidden email] wrote:
Did you try to use credentials in jenkins to store the token  instead of  fiddling  with token on the machine?

Then you could do everything in one job instead of  doing some copy-magic (which would  horribly break once you start to use more nodes).

Björn
[hidden email] schrieb am Samstag, 27. März 2021 um 04:05:44 UTC+1:
Thanks Mark, I'll check it out.  Has to beat the hokey workaround I worked up.  :)



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 10:49 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

Good point.  How about the external workspace plugin from GSoC 2016?  https://plugins.jenkins.io/external-workspace-manager/

On Fri, Mar 26, 2021 at 8:00 PM eric.fetzer <[hidden email]> wrote:
Thanks for the response Mark..  I'm using freestyle.  Doesn't checkout to a subdirectory only take relative paths?



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 6:44 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

If you're using pipeline, change to that directory with the dir('/users/username/projectname') { } wrapper around the checkout step;

If you're using a freestyle job, use the git plugin extension 'checkout to a subdirectory'

On Fri, Mar 26, 2021 at 10:54 AM [hidden email] <[hidden email]> wrote:
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG6VTjt8F7Vj5pJW13VQJTfxCqRuZuDHjj5zZTa3jJ9%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/605e9199.1c69fb81.932c2.d78c%40mx.google.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/921876ab-23ac-4272-b990-04925cf8352bn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Where I got the info to make this work, Bjorn, is from the thread that your thread referenced:

https://stackoverflow.com/questions/56809684/git-clone-in-jenkins-with-personal-access-token-idles-forever/61104603#61104603

It was a bit painful, but at least it gets it done.  What I've implemented is passing the workspace to the checkout, checking out as my user to my user workspace (home directory), moving the files checked out to the jenkins workspace, using sudo to chown the folder and files to be owned by the jenkins user.  It's very crude but it works.  I'm going to take a look at Mark's option above, but at least I found something that will work...

On Mon, Mar 29, 2021 at 7:14 AM [hidden email] <[hidden email]> wrote:
Yes Bjorn, that's the thread I used to figure out how to use the access token.  Unfortunately, the jenkins plugin isn't smart enough to pass a username, it uses the username it runs as.  So my master node is running as the user "jenkins" so it tries to authenticate to GitHub Enterprise as jenkins:<myToken which of course fails.  So I created a different node to run as my user, which thankfully, is the same username as I have in GitHub Enterprise.  Smoke and mirrors...

On Monday, March 29, 2021 at 3:26:47 AM UTC-6 [hidden email] wrote:
Did you try to use credentials in jenkins to store the token  instead of  fiddling  with token on the machine?

Then you could do everything in one job instead of  doing some copy-magic (which would  horribly break once you start to use more nodes).

Björn
[hidden email] schrieb am Samstag, 27. März 2021 um 04:05:44 UTC+1:
Thanks Mark, I'll check it out.  Has to beat the hokey workaround I worked up.  :)



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 10:49 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

Good point.  How about the external workspace plugin from GSoC 2016?  https://plugins.jenkins.io/external-workspace-manager/

On Fri, Mar 26, 2021 at 8:00 PM eric.fetzer <[hidden email]> wrote:
Thanks for the response Mark..  I'm using freestyle.  Doesn't checkout to a subdirectory only take relative paths?



Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Mark Waite <[hidden email]>
Date: 3/26/21 6:44 PM (GMT-05:00)
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

If you're using pipeline, change to that directory with the dir('/users/username/projectname') { } wrapper around the checkout step;

If you're using a freestyle job, use the git plugin extension 'checkout to a subdirectory'

On Fri, Mar 26, 2021 at 10:54 AM [hidden email] <[hidden email]> wrote:
OK, so this is kind of complex so hang with me.  We're moving from StarTeam to Github and I'm trying to reproduce what I'm doing in StarTeam with Github.  StarTeam was easy because I owned the repository machine as well as administrated the tool.  With Github, we're hosted.  So I'm admin on the project but can't create an RSA Token on the machine for easy access.  So I had to play around to make a personal access token work.  In order to make that access token work, I had to run the checkout job on a different node so that it was running as a user that lived in Github as well (access token's namesake).  So when this job gets called from the jenkins job, I want it to clone to the calling job's workspace (/opt/jenkins/workspace/<project_name>).  Well since in order to authenticate, it lives in it's own shell, the workspace for this guy, and where it wants to clone to, is /home/<username>/<project_name>.  All that for my question:  how can I specify what folder to checkout to?  I tried to use "checkout to specific local branch" but it fails saying "is not a valid branch name".  Well, yeah, branch is referring to branch not folder, lol.  In StarTeam this is easy, you just specify working folder.  Any help?  Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/128374b8-63d5-4b8c-86bb-5f214f5e68d2n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG6VTjt8F7Vj5pJW13VQJTfxCqRuZuDHjj5zZTa3jJ9%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/605e9199.1c69fb81.932c2.d78c%40mx.google.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/921876ab-23ac-4272-b990-04925cf8352bn%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicYf0HetcEGPDKcZ6voFSuFs6yGtrVzaWeZaFxJvSpLneA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Dirk Heinrichs-3
Am Montag, den 29.03.2021, 07:22 -0600 schrieb Eric Fetzer:

It was a bit painful, but at least it gets it done.  What I've implemented is passing the workspace to the checkout, checking out as my user to my user workspace (home directory), moving the files checked out to the jenkins workspace, using sudo to chown the folder and files to be owned by the jenkins user.  It's very crude but it works.  I'm going to take a look at Mark's option above, but at least I found something that will work...

We've been doing GitHub checkouts from Jenkins for quite some time (until we moved the other way round, to a self-hosted GitLab), and didn't have any problems. However, we used SSH keys, which can be added to Jenkins Credentials and then used by the plain Git plugin in any Freestyle or Pipeline job.

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Website: <a href="mail://ab5defde1fa49913f64f8482009c4be447b3cf96/Gesendete%20Elemente/www.recommind.de">www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1f5a073cd7dd8172fff194b00193e4b52f6b2772.camel%40opentext.com.

signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

On Mon, Mar 29, 2021 at 7:40 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:
Am Montag, den 29.03.2021, 07:22 -0600 schrieb Eric Fetzer:

It was a bit painful, but at least it gets it done.  What I've implemented is passing the workspace to the checkout, checking out as my user to my user workspace (home directory), moving the files checked out to the jenkins workspace, using sudo to chown the folder and files to be owned by the jenkins user.  It's very crude but it works.  I'm going to take a look at Mark's option above, but at least I found something that will work...

We've been doing GitHub checkouts from Jenkins for quite some time (until we moved the other way round, to a self-hosted GitLab), and didn't have any problems. However, we used SSH keys, which can be added to Jenkins Credentials and then used by the plain Git plugin in any Freestyle or Pipeline job.

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1f5a073cd7dd8172fff194b00193e4b52f6b2772.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicbPEtLAfdTx6ta6UKRyxKotYYhH1Xo1-r3DmR_A__X0pQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Dirk Heinrichs-3
Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Website: <a href="mail://ab5defde1fa49913f64f8482009c4be447b3cf96/Gesendete%20Elemente/www.recommind.de">www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.com.

signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Ohhhh, duh, I get it now.  I create the key with the jenkins user and add id_rsa.pub to the GitHub account for access.  I was somehow thinking I would need a key on the GitHub side.  Feeling kind of foolish now, lol.  Thanks Dirk!

On Mon, Mar 29, 2021 at 7:52 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:
Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicYr9i_qnSwUPmqMHR5Q-NOd4hpN455dyAZNXLRHJzEGYw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Hmmm, thought that was going to work but it didn't.  I followed everything to a T at:  https://mohitgoyal.co/2017/02/27/configuring-ssh-authentication-between-github-and-jenkins/
The output shows:

Building on master in workspace /var/lib/jenkins/workspace/Git-Checkout
using credential JenkinsSSHKey
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://myGitRepo.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Fetching upstream changes from https://myGitRepo.git
 > git --version # timeout=10
using GIT_SSH to set credentials 

So I see it's using the creds.  Then when it tries to do the fetch, it says:

 > git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://myGitRepo.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
	at hudson.scm.SCM.checkout(SCM.java:505)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
	at hudson.model.Run.execute(Run.java:1907)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.


On Mon, Mar 29, 2021 at 8:09 AM Eric Fetzer <[hidden email]> wrote:
Ohhhh, duh, I get it now.  I create the key with the jenkins user and add id_rsa.pub to the GitHub account for access.  I was somehow thinking I would need a key on the GitHub side.  Feeling kind of foolish now, lol.  Thanks Dirk!

On Mon, Mar 29, 2021 at 7:52 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:
Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicb7irzVcbgHO0vV39EE7f515%3DVCkcHqrYE5eefkjbZT%3Dg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Mark Waite-2
You can't use ssh authentication with an https repository URL.  When using ssh authentication, you need to use an ssh repository URL.  When using username / password or username / token, you must use an HTTPS (or HTTP) URL.

Mark Waite

On Mon, Mar 29, 2021 at 10:38 AM Eric Fetzer <[hidden email]> wrote:
Hmmm, thought that was going to work but it didn't.  I followed everything to a T at:  https://mohitgoyal.co/2017/02/27/configuring-ssh-authentication-between-github-and-jenkins/
The output shows:

Building on master in workspace /var/lib/jenkins/workspace/Git-Checkout
using credential JenkinsSSHKey
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://myGitRepo.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Fetching upstream changes from https://myGitRepo.git
 > git --version # timeout=10
using GIT_SSH to set credentials 

So I see it's using the creds.  Then when it tries to do the fetch, it says:

 > git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://myGitRepo.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
	at hudson.scm.SCM.checkout(SCM.java:505)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
	at hudson.model.Run.execute(Run.java:1907)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.


On Mon, Mar 29, 2021 at 8:09 AM Eric Fetzer <[hidden email]> wrote:
Ohhhh, duh, I get it now.  I create the key with the jenkins user and add id_rsa.pub to the GitHub account for access.  I was somehow thinking I would need a key on the GitHub side.  Feeling kind of foolish now, lol.  Thanks Dirk!

On Mon, Mar 29, 2021 at 7:52 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:
Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicb7irzVcbgHO0vV39EE7f515%3DVCkcHqrYE5eefkjbZT%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHV-NmyYicCX7bUAH%2B1QZSCXT6aFc7-0fKCOS70T4QU%2BA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
Thanks Mark!  I believe I'm one step closer but it's still not working.  I'm now getting:

Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@myURLRepo:myUser/myProject.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: ssh: connect to host myURLRepo port 22: Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.



On Monday, March 29, 2021 at 11:23:28 AM UTC-6 Mark Waite wrote:
You can't use ssh authentication with an https repository URL.  When using ssh authentication, you need to use an ssh repository URL.  When using username / password or username / token, you must use an HTTPS (or HTTP) URL.

Mark Waite

On Mon, Mar 29, 2021 at 10:38 AM Eric Fetzer <[hidden email]> wrote:
Hmmm, thought that was going to work but it didn't.  I followed everything to a T at:  https://mohitgoyal.co/2017/02/27/configuring-ssh-authentication-between-github-and-jenkins/
The output shows:

Building on master in workspace /var/lib/jenkins/workspace/Git-Checkout
using credential JenkinsSSHKey
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://myGitRepo.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Fetching upstream changes from https://myGitRepo.git
 > git --version # timeout=10
using GIT_SSH to set credentials 

So I see it's using the creds.  Then when it tries to do the fetch, it says:

 > git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://myGitRepo.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
	at hudson.scm.SCM.checkout(SCM.java:505)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
	at hudson.model.Run.execute(Run.java:1907)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.


On Mon, Mar 29, 2021 at 8:09 AM Eric Fetzer <[hidden email]> wrote:
Ohhhh, duh, I get it now.  I create the key with the jenkins user and add id_rsa.pub to the GitHub account for access.  I was somehow thinking I would need a key on the GitHub side.  Feeling kind of foolish now, lol.  Thanks Dirk!

On Mon, Mar 29, 2021 at 7:52 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:
Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: <a href="tel:+49%202226%201596618" value="+4922261596618" target="_blank" rel="nofollow">+49 2226 15966 18
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicb7irzVcbgHO0vV39EE7f515%3DVCkcHqrYE5eefkjbZT%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d18ca0d2-ee3e-44b5-b6b4-7646e9489b56n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
The only thing I can guess is that ssh is getting a question when he attempts to connect wanting to be added to the known_hosts file.  Wondering if maybe there's a way to establish this if this is indeed the issue?

On Monday, March 29, 2021 at 12:07:01 PM UTC-6 [hidden email] wrote:
Thanks Mark!  I believe I'm one step closer but it's still not working.  I'm now getting:

Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@myURLRepo:myUser/myProject.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: ssh: connect to host myURLRepo port 22: Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.



On Monday, March 29, 2021 at 11:23:28 AM UTC-6 Mark Waite wrote:
You can't use ssh authentication with an https repository URL.  When using ssh authentication, you need to use an ssh repository URL.  When using username / password or username / token, you must use an HTTPS (or HTTP) URL.

Mark Waite

On Mon, Mar 29, 2021 at 10:38 AM Eric Fetzer <[hidden email]> wrote:
Hmmm, thought that was going to work but it didn't.  I followed everything to a T at:  https://mohitgoyal.co/2017/02/27/configuring-ssh-authentication-between-github-and-jenkins/
The output shows:

Building on master in workspace /var/lib/jenkins/workspace/Git-Checkout
using credential JenkinsSSHKey
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://myGitRepo.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Fetching upstream changes from https://myGitRepo.git
 > git --version # timeout=10
using GIT_SSH to set credentials 

So I see it's using the creds.  Then when it tries to do the fetch, it says:

 > git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://myGitRepo.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
	at hudson.scm.SCM.checkout(SCM.java:505)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
	at hudson.model.Run.execute(Run.java:1907)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.


On Mon, Mar 29, 2021 at 8:09 AM Eric Fetzer <[hidden email]> wrote:
Ohhhh, duh, I get it now.  I create the key with the jenkins user and add id_rsa.pub to the GitHub account for access.  I was somehow thinking I would need a key on the GitHub side.  Feeling kind of foolish now, lol.  Thanks Dirk!

On Mon, Mar 29, 2021 at 7:52 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:
Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: <a href="tel:+49%202226%201596618" value="+4922261596618" rel="nofollow" target="_blank">+49 2226 15966 18
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicb7irzVcbgHO0vV39EE7f515%3DVCkcHqrYE5eefkjbZT%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/578014bd-9a78-49c9-99fb-2b0ab66c2354n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Jérôme Godbout

I do add the domain and hsot to my known host file before to avoid that nasty confirm:

 

sh("ssh -R ${domain} -f \".ssh/known_hosts\"")

sh("ssh -t rsa ${domain} >> \".ssh/known_hosts\"")

 

that should do the trick and avoid that prompt when later used. Use the domain of the repos url domain.

 

Jérôme Godbout, B. Ing.


Software / Firmware Team Lead
O: (418) 682-3636 ext.: 114  

C: (581) 777-0050 
[hidden email]

signature_168530195

dimonoff.com

1015 Avenue Wilfrid-Pelletier, 

Québec, QC G1W 0C4, 4e étage

 

 

From: [hidden email] <[hidden email]> on behalf of [hidden email] <[hidden email]>
Date: Monday, March 29, 2021 at 3:27 PM
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

The only thing I can guess is that ssh is getting a question when he attempts to connect wanting to be added to the known_hosts file.  Wondering if maybe there's a way to establish this if this is indeed the issue?

On Monday, March 29, 2021 at 12:07:01 PM UTC-6 [hidden email] wrote:

Thanks Mark!  I believe I'm one step closer but it's still not working.  I'm now getting:

 

Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@myURLRepo:myUser/myProject.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: ssh: connect to host myURLRepo port 22: Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

 

 

 

On Monday, March 29, 2021 at 11:23:28 AM UTC-6 Mark Waite wrote:

You can't use ssh authentication with an https repository URL.  When using ssh authentication, you need to use an ssh repository URL.  When using username / password or username / token, you must use an HTTPS (or HTTP) URL.

 

Mark Waite

 

On Mon, Mar 29, 2021 at 10:38 AM Eric Fetzer <[hidden email]> wrote:

Hmmm, thought that was going to work but it didn't.  I followed everything to a T at:  https://mohitgoyal.co/2017/02/27/configuring-ssh-authentication-between-github-and-jenkins/

The output shows:


Building on master in workspace /var/lib/jenkins/workspace/Git-Checkout
using credential JenkinsSSHKey
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://myGitRepo.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Fetching upstream changes from https://myGitRepo.git
 > git --version # timeout=10
using GIT_SSH to set credentials 

 

So I see it's using the creds.  Then when it tries to do the fetch, it says:

 

 > git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://myGitRepo.git
     at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
     at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
     at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
     at hudson.scm.SCM.checkout(SCM.java:505)
     at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
     at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
     at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
     at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
     at hudson.model.Run.execute(Run.java:1907)
     at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
     at hudson.model.ResourceController.execute(ResourceController.java:97)
     at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.

 

 

On Mon, Mar 29, 2021 at 8:09 AM Eric Fetzer <[hidden email]> wrote:

Ohhhh, duh, I get it now.  I create the key with the jenkins user and add id_rsa.pub to the GitHub account for access.  I was somehow thinking I would need a key on the GitHub side.  Feeling kind of foolish now, lol.  Thanks Dirk!

 

On Mon, Mar 29, 2021 at 7:52 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:

Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

 

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

 

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

 

Bye...

 

Dirk

-- 

Dirk Heinrichs

Senior Systems Engineer, Delivery Pipeline

OpenText ™ Discovery | Recommind

Phone: <a href="tel:+49%202226%201596618" target="_blank"> +49 2226 15966 18

Email[hidden email]

Website: www.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicb7irzVcbgHO0vV39EE7f515%3DVCkcHqrYE5eefkjbZT%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/578014bd-9a78-49c9-99fb-2b0ab66c2354n%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/QB1PR01MB38441677B7426D136A949FBFCD7E9%40QB1PR01MB3844.CANPRD01.PROD.OUTLOOK.COM.
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Dirk Heinrichs-3
In reply to this post by Eric Fetzer
Am Montag, den 29.03.2021, 11:07 -0700 schrieb [hidden email]:

Please make sure you have the correct access rights and the repository exists.

Oh, yes, forgot that: On the host(s) that does/do the cloning, you need to either
  • connect to [hidden email] once per SSH on the console and as the user who runs Jenkins, to add the GH host key to that users known_hosts file, or
  • add a host block to that users ~/.ssh/config file like:
    host github
           Hostname github.com
           User git
           IdentityFile ~/.ssh/my_github_key
           ServerAliveInterval 15
           
    StrictHostKeyChecking no

In the second case, you also don't need to store the credentials in Jenkins, since you can use the alias "github" directly in your URLs, like "github:path/to/repo" (instead of "[hidden email]:..."). If you're reluctant to skip host key verification, you can also omit the last line and combine the two methods.

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Website: <a href="mail://ab5defde1fa49913f64f8482009c4be447b3cf96/Gesendete%20Elemente/www.recommind.de">www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/326bd980bf6fb0c452acc3581fbdda80ec870166.camel%40opentext.com.

signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Dirk Heinrichs-3
Am Dienstag, den 30.03.2021, 05:59 +0000 schrieb 'Dirk Heinrichs' via Jenkins Users:
Am Montag, den 29.03.2021, 11:07 -0700 schrieb [hidden email]:

Please make sure you have the correct access rights and the repository exists.

Oh, yes, forgot that: On the host(s) that does/do the cloning, you need to either
  • connect to [hidden email] once per SSH on the console and as the user who runs Jenkins, to add the GH host key to that users known_hosts file, or
  • add a host block to that users ~/.ssh/config file like:
    host github
           Hostname github.com
           User git
           IdentityFile ~/.ssh/my_github_key
           ServerAliveInterval 15
           
    StrictHostKeyChecking no

In the second case, you also don't need to store the credentials in Jenkins, since you can use the alias "github" directly in your URLs, like "github:path/to/repo" (instead of "[hidden email]:..."). If you're reluctant to skip host key verification, you can also omit the last line and combine the two methods.

If you are running many Jenkins agents you can of course do the first step once on one of them and then copy the GH host key into either the user's ~/.ssh/.known_hosts or the global /etc/ssh/ssh_known_hosts file on the other ones.

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Website: <a href="mail://ab5defde1fa49913f64f8482009c4be447b3cf96/Gesendete%20Elemente/www.recommind.de">www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/555dfc6a05436febb4f16d0a5d81b7a1c4c3f928.camel%40opentext.com.

signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GitHub Clone to Different Local Directory

Eric Fetzer
In reply to this post by Jérôme Godbout
So the url is [hidden email] and I tried to use your first command with a.b.c.d for domain and got "bad remote forwarding specification".  I tried it with b.c.d and c.d as well resulting in the same error.  Any ideas?  Thanks!

On Mon, Mar 29, 2021 at 2:06 PM Jérôme Godbout <[hidden email]> wrote:

I do add the domain and hsot to my known host file before to avoid that nasty confirm:

 

sh("ssh -R ${domain} -f \".ssh/known_hosts\"")

sh("ssh -t rsa ${domain} >> \".ssh/known_hosts\"")

 

that should do the trick and avoid that prompt when later used. Use the domain of the repos url domain.

 

Jérôme Godbout, B. Ing.


Software / Firmware Team Lead
O: (418) 682-3636 ext.: 114  

C: (581) 777-0050 
[hidden email]

signature_168530195

dimonoff.com

1015 Avenue Wilfrid-Pelletier, 

Québec, QC G1W 0C4, 4e étage

 

 

From: [hidden email] <[hidden email]> on behalf of [hidden email] <[hidden email]>
Date: Monday, March 29, 2021 at 3:27 PM
To: Jenkins Users <[hidden email]>
Subject: Re: GitHub Clone to Different Local Directory

The only thing I can guess is that ssh is getting a question when he attempts to connect wanting to be added to the known_hosts file.  Wondering if maybe there's a way to establish this if this is indeed the issue?

On Monday, March 29, 2021 at 12:07:01 PM UTC-6 [hidden email] wrote:

Thanks Mark!  I believe I'm one step closer but it's still not working.  I'm now getting:

 

Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@myURLRepo:myUser/myProject.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: ssh: connect to host myURLRepo port 22: Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

 

 

 

On Monday, March 29, 2021 at 11:23:28 AM UTC-6 Mark Waite wrote:

You can't use ssh authentication with an https repository URL.  When using ssh authentication, you need to use an ssh repository URL.  When using username / password or username / token, you must use an HTTPS (or HTTP) URL.

 

Mark Waite

 

On Mon, Mar 29, 2021 at 10:38 AM Eric Fetzer <[hidden email]> wrote:

Hmmm, thought that was going to work but it didn't.  I followed everything to a T at:  https://mohitgoyal.co/2017/02/27/configuring-ssh-authentication-between-github-and-jenkins/

The output shows:


Building on master in workspace /var/lib/jenkins/workspace/Git-Checkout
using credential JenkinsSSHKey
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://myGitRepo.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Fetching upstream changes from https://myGitRepo.git
 > git --version # timeout=10
using GIT_SSH to set credentials 

 

So I see it's using the creds.  Then when it tries to do the fetch, it says:

 

 > git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://myGitRepo.git
     at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
     at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
     at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
     at hudson.scm.SCM.checkout(SCM.java:505)
     at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
     at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
     at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
     at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
     at hudson.model.Run.execute(Run.java:1907)
     at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
     at hudson.model.ResourceController.execute(ResourceController.java:97)
     at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://myGitRepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.

 

 

On Mon, Mar 29, 2021 at 8:09 AM Eric Fetzer <[hidden email]> wrote:

Ohhhh, duh, I get it now.  I create the key with the jenkins user and add id_rsa.pub to the GitHub account for access.  I was somehow thinking I would need a key on the GitHub side.  Feeling kind of foolish now, lol.  Thanks Dirk!

 

On Mon, Mar 29, 2021 at 7:52 AM 'Dirk Heinrichs' via Jenkins Users <[hidden email]> wrote:

Am Montag, den 29.03.2021, 07:44 -0600 schrieb Eric Fetzer:

 

Thanks for your reply Dirk!  I'm a unix guy and that would have been my first choice, however I don't have access to the GitHub OS, only my particular repositories.

 

I don't understand. Nobody has this kind of access. But everybody can add SSH keys to their GH account (using the web UI).

 

Bye...

 

Dirk

-- 

Dirk Heinrichs

Senior Systems Engineer, Delivery Pipeline

OpenText ™ Discovery | Recommind

Phone: <a href="tel:+49%202226%201596618" target="_blank"> +49 2226 15966 18

Email[hidden email]

Websitewww.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7363fbe30406b54bee9b6671dc9754cbf78081c7.camel%40opentext.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicb7irzVcbgHO0vV39EE7f515%3DVCkcHqrYE5eefkjbZT%3Dg%40mail.gmail.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/578014bd-9a78-49c9-99fb-2b0ab66c2354n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/Ob42FqU-0UY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/QB1PR01MB38441677B7426D136A949FBFCD7E9%40QB1PR01MB3844.CANPRD01.PROD.OUTLOOK.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAByBicbOCiWvNLhhATFmhKAH0YPsB%3DZUDCbAHESpK9grnya1WQ%40mail.gmail.com.
12