git operations over ssh in Windows agent

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

git operations over ssh in Windows agent

Andreas Tscharner-2
Hello World,

I have the following setup:

git Server: Debian Linux 9.1
Jenkins master: Debian Linux 9.1
Jenkins agent: Windows 7

I created a user on the git server for building, it is called "build". I
also have created a ssh key-pair for that user. The public key is in the
authorized_keys file on the git server. I have installed PuTTY on the
Windows agent, and I autostart Pageant with the key for the user
"build". git v2.14.2 is installed on Windows as well and GIT_SSH
contains the full path to PuTTY plink.exe. If I use PuTTY to log in to
the git server, it works without a problem (and without a password as
well as Pageant serves the key).

I now wanted to use this setup with Jenkins and it always fails. If I
enter the git commands it shows on the console output on a cmd.exe it
works, but it does not work with Jenkins.

I tried with the credentials username/password, I get:
Cloning repository ssh://git.metromec.ch/repositories/quartis.git
  > git init C:\Jenkins-Jobs\workspace\Branch-origin-features-QT-7889 #
timeout=10
Fetching upstream changes from
ssh://git.metromec.ch/repositories/quartis.git
  > git --version # timeout=10
using GIT_ASKPASS to set credentials Build user from the VMs
  > git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: fatal: protocol error: bad line length character: logi

I tried without credentials from Jenkins, using the username directly in
the repository string (thinking Pageant is running and will provide the
key):
Cloning repository ssh://[hidden email]/repositories/quartis.git
  > git init C:\Jenkins-Jobs\workspace\Branch-origin-features-QT-7889 #
timeout=10
Fetching upstream changes from
ssh://[hidden email]/repositories/quartis.git
  > git --version # timeout=10
  > git fetch --tags --progress
ssh://[hidden email]/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
ssh://[hidden email]/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: fatal: protocol error: bad line length character: buil

I also tried username/private key from Jenkins and got:
Cloning repository ssh://git.metromec.ch/repositories/quartis.git
  > git init C:\Jenkins-Jobs\workspace\Branch-origin-features-QT-7889 #
timeout=10
Fetching upstream changes from
ssh://git.metromec.ch/repositories/quartis.git
  > git --version # timeout=10
using GIT_SSH to set credentials Build user from the VMs (with key)
  > git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: plink: unknown option "-o"
fatal: Could not read from remote repository.

How do I provide the correct credentials for this user in this setup?

TIA and best regards
        Andreas
--
Andreas Tscharner                             [hidden email]

Gordon's Law:
If you think you have the solution, the question was poorly phrased.

--
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/d92a7ac0-9a49-c423-ca34-722604050156%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: git operations over ssh in Windows agent

Mark Waite-2
I don't use putty and plink in my Windows based test setup for the git plugin.  Can you share the key reasons you chose those non-default installation options?

Mark Waite

On Thu, Sep 28, 2017 at 8:55 AM Andreas Tscharner <[hidden email]> wrote:
Hello World,

I have the following setup:

git Server: Debian Linux 9.1
Jenkins master: Debian Linux 9.1
Jenkins agent: Windows 7

I created a user on the git server for building, it is called "build". I
also have created a ssh key-pair for that user. The public key is in the
authorized_keys file on the git server. I have installed PuTTY on the
Windows agent, and I autostart Pageant with the key for the user
"build". git v2.14.2 is installed on Windows as well and GIT_SSH
contains the full path to PuTTY plink.exe. If I use PuTTY to log in to
the git server, it works without a problem (and without a password as
well as Pageant serves the key).

I now wanted to use this setup with Jenkins and it always fails. If I
enter the git commands it shows on the console output on a cmd.exe it
works, but it does not work with Jenkins.

I tried with the credentials username/password, I get:
Cloning repository ssh://git.metromec.ch/repositories/quartis.git
  > git init C:\Jenkins-Jobs\workspace\Branch-origin-features-QT-7889 #
timeout=10
Fetching upstream changes from
ssh://git.metromec.ch/repositories/quartis.git
  > git --version # timeout=10
using GIT_ASKPASS to set credentials Build user from the VMs
  > git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: fatal: protocol error: bad line length character: logi

I tried without credentials from Jenkins, using the username directly in
the repository string (thinking Pageant is running and will provide the
key):
Cloning repository ssh://build@.../repositories/quartis.git
  > git init C:\Jenkins-Jobs\workspace\Branch-origin-features-QT-7889 #
timeout=10
Fetching upstream changes from
ssh://build@.../repositories/quartis.git
  > git --version # timeout=10
  > git fetch --tags --progress
ssh://build@.../repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
ssh://build@.../repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: fatal: protocol error: bad line length character: buil

I also tried username/private key from Jenkins and got:
Cloning repository ssh://git.metromec.ch/repositories/quartis.git
  > git init C:\Jenkins-Jobs\workspace\Branch-origin-features-QT-7889 #
timeout=10
Fetching upstream changes from
ssh://git.metromec.ch/repositories/quartis.git
  > git --version # timeout=10
using GIT_SSH to set credentials Build user from the VMs (with key)
  > git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
ssh://git.metromec.ch/repositories/quartis.git
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: plink: unknown option "-o"
fatal: Could not read from remote repository.

How do I provide the correct credentials for this user in this setup?

TIA and best regards
        Andreas
--
Andreas Tscharner                             [hidden email]

Gordon's Law:
If you think you have the solution, the question was poorly phrased.

--
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/d92a7ac0-9a49-c423-ca34-722604050156%40gmail.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtEYDwTvjvfhVUifMMY3x6pWY1UgNDXnnTWuk-kL5JG%2BbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: git operations over ssh in Windows agent

Andreas Tscharner-2
On 28.09.2017 17:12, Mark Waite wrote:
> I don't use putty and plink in my Windows based test setup for the git
> plugin.  Can you share the key reasons you chose those non-default
> installation options?
>

IMHO PuTTY is THE ssh client for Windows (first hit with Google ("ssh
for Windows"), used by TortoiseGit and TortoiseSVN); and because I
already had installed it when we switched to git, I used it.

I assume the git plugin does not work with PuTTY?

Best regards
        Andreas
--
Andreas Tscharner                             [hidden email]

Gordon's Law:
If you think you have the solution, the question was poorly phrased.

--
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/39dfff85-06cd-0cb7-7934-45d55c12cec3%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: git operations over ssh in Windows agent

Dirk Heinrichs-3
In reply to this post by Andreas Tscharner-2
Am 28.09.2017 um 16:54 schrieb Andreas Tscharner:
Hello World,

I have the following setup:

git Server: Debian Linux 9.1
Jenkins master: Debian Linux 9.1
Jenkins agent: Windows 7

I created a user on the git server for building, it is called "build". I also have created a ssh key-pair for that user. The public key is in the authorized_keys file on the git server. I have installed PuTTY on the Windows agent, and I autostart Pageant with the key for the user "build". git v2.14.2 is installed on Windows as well and GIT_SSH contains the full path to PuTTY plink.exe. If I use PuTTY to log in to the git server, it works without a problem (and without a password as well as Pageant serves the key).

I now wanted to use this setup with Jenkins and it always fails. If I enter the git commands it shows on the console output on a cmd.exe it works, but it does not work with Jenkins.

I tried with the credentials username/password, I get:
Cloning repository <a class="moz-txt-link-freetext" href="ssh://git.metromec.ch/repositories/quartis.git">ssh://git.metromec.ch/repositories/quartis.git
 > git init C:\Jenkins-Jobs\workspace\Branch-origin-features-QT-7889 # timeout=10
Fetching upstream changes from <a class="moz-txt-link-freetext" href="ssh://git.metromec.ch/repositories/quartis.git">ssh://git.metromec.ch/repositories/quartis.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Build user from the VMs
 > git fetch --tags --progress <a class="moz-txt-link-freetext" href="ssh://git.metromec.ch/repositories/quartis.git">ssh://git.metromec.ch/repositories/quartis.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress <a class="moz-txt-link-freetext" href="ssh://git.metromec.ch/repositories/quartis.git">ssh://git.metromec.ch/repositories/quartis.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: fatal: protocol error: bad line length character: logi

This looks to me as if you were trying to run the git commands from an "Execute Windows Batch" step in your Jenkins job. It's far easier to simply use the Git plugin to do the job together with the SSH key you provided to Jenkins via "Manage Jenkins" -> "Credentials". This can also be configured to use JGit so that you don't even need GfW installed.

HTH...

    Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenTextTM Discovery | Recommind
Email: [hidden email]
Website: www.recommind.de

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

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, 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/0a30b0ba-ce0e-43e1-b1ef-9492f36ebb71%40opentext.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: git operations over ssh in Windows agent

Andreas Tscharner-2
On 29.09.2017 09:11, Dirk Heinrichs wrote:
>
> This looks to me as if you were trying to run the git commands from an
> "Execute Windows Batch" step in your Jenkins job. It's far easier to
> simply use the Git plugin to do the job together with the SSH key you
> provided to Jenkins via "Manage Jenkins" -> "Credentials". This can also
> be configured to use JGit so that you don't even need GfW installed.
>

Actually that is the console output of a
checkout([$class: 'GitSCM', branches:....
line (within the first stage) with tries username/password, username/key
and no credentials using the username in the repository line ("user@git...")

Best regards
        Andreas
--
Andreas Tscharner                             [hidden email]

Gordon's Law:
If you think you have the solution, the question was poorly phrased.

--
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/b2a1bc5e-6683-1904-f736-9bf873a29e20%40gmail.com.
For more options, visit https://groups.google.com/d/optout.