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

"Checkout over SSH" fails the build since it still uses HTTPS urls

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins ver. 2.60.2
      Cloudbees BitBucket Branch Source Plugin v. 2.2.3

      I've configured the option "Checkout over SSH". Yet, the HTTPS url is used, as we can see in the build log:

       

      Branch indexing
      Checking out git https://bitbucket.org/my-org/my-app-android.git into /var/jenkins_home/workspace/-app-android_avoid-os-clone-3HZZVSGHH7HARS2F37PQWWMN7OXA3M6XXBAQKXVEMDJZEPDIH6VQ@script to read Jenkinsfile
      Cloning the remote Git repository
      Cloning with configured refspecs honoured and without tags
      Cloning repository https://bitbucket.org/my-org/my-app-android.git
      > git init /var/jenkins_home/workspace/-app-android_avoid-os-clone-3HZZVSGHH7HARS2F37PQWWMN7OXA3M6XXBAQKXVEMDJZEPDIH6VQ@script # timeout=10
      Fetching upstream changes from https://bitbucket.org/my-org/my-app-android.git
      > git -version # timeout=10
      > git fetch -no-tags -progress https://bitbucket.org/my-org/my-app-android.git +refs/heads/avoid-os-clone:refs/remotes/origin/avoid-os-clone
      ERROR: Error cloning remote repo 'origin'
      hudson.plugins.git.GitException: Command "git fetch -no-tags -progress https://bitbucket.org/my-org/my-app-android.git +refs/heads/avoid-os-clone:refs/remotes/origin/avoid-os-clone" returned status code 128:
      stdout: 
      stderr: remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
      fatal: Authentication failed for 'https://bitbucket.org/my-org/my-app-android.git/'
      

          [JENKINS-46094] "Checkout over SSH" fails the build since it still uses HTTPS urls

          Elifarley created issue -
          Elifarley made changes -
          Description New: I've configured the option "Checkout over SSH". Yet, the HTTPS url is used, as we can see in the build log:

           
          {code:java}
          Branch indexing
          Checking out git https://bitbucket.org/my-org/my-app-android.git into /var/jenkins_home/workspace/-app-android_avoid-os-clone-3HZZVSGHH7HARS2F37PQWWMN7OXA3M6XXBAQKXVEMDJZEPDIH6VQ@script to read Jenkinsfile
          Cloning the remote Git repository
          Cloning with configured refspecs honoured and without tags
          Cloning repository https://bitbucket.org/my-org/my-app-android.git
          > git init /var/jenkins_home/workspace/-app-android_avoid-os-clone-3HZZVSGHH7HARS2F37PQWWMN7OXA3M6XXBAQKXVEMDJZEPDIH6VQ@script # timeout=10
          Fetching upstream changes from https://bitbucket.org/my-org/my-app-android.git
          > git -version # timeout=10
          > git fetch -no-tags -progress https://bitbucket.org/my-org/my-app-android.git +refs/heads/avoid-os-clone:refs/remotes/origin/avoid-os-clone
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Command "git fetch -no-tags -progress https://bitbucket.org/my-org/my-app-android.git +refs/heads/avoid-os-clone:refs/remotes/origin/avoid-os-clone" returned status code 128:
          stdout:
          stderr: remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
          fatal: Authentication failed for 'https://bitbucket.org/my-org/my-app-android.git/'
          {code}

          James Dumay added a comment -

          elifarley can you please provide a bit more information about this one? Any reproduction steps would be a great help

          James Dumay added a comment - elifarley can you please provide a bit more information about this one? Any reproduction steps would be a great help

          Craig Paton added a comment -

          I had the same problem.  I was able to trigger SSH to be used by selecting an explicit SSH key for the credentials. "- use build agents key-" would be ignored and result in HTTPS being used.

          Craig Paton added a comment - I had the same problem.  I was able to trigger SSH to be used by selecting an explicit SSH key for the credentials. "- use build agents key-" would be ignored and result in HTTPS being used.

          Josh Soref added a comment -

          The way we hit this was by using the GitHub Organization object from /view/Main/newJob.

          GitHub Organization

          • Credentials User Account for GitHub (username+password)
          • Owner (the name of the GitHub Organization)
          • Behaviors:
            • – Repositories –
            • Filter by name (with wildcards)
            • Include: something – note: this wasn't relevant
            • Exclude_blank_ – also not relevant
            • – Within repository –
            • Discover branches
              • Strategy: Exclude branches that are also filed as PRs – note: this isn't relevant, and I think it's the default
            • Discover pull requests from origin
              • Strategy: Both the current pull request revision and the pull request merged with the current target branch revision – note: this isn't relevant
            • Discover pull requests from forks
              • Strategy: Both the current pull request revision and the pull request merged with the current target branch revision – note: this isn't relevant
            • Trust: From users with Admin or Write permission – note: this isn't relevant, and I think it's the default
            • – Additional –
            • Check out to matching local branch – this shouldn't be relevant, but it's necessary for our tooling, since we're trying to automatically push tags in some cases.

          Project Recognizers

          • Pipeline Jenkinsfile
            • Script Path: slightly non-standard – note: this isn't relevant

          Scan Organization Triggers

          [x] Periodically if not otherwise run

          Interval: 1 day  – note: this isn't relevant, and I think it's the default


          Orphaned Item Strategy

          [x] Discard old items – note: this isn't relevant, and I think it's the default

          Days to keep old items: blank – note: this isn't relevant, and I think it's the default

          Max # of old items to keep: blank – note: this isn't relevant, and I think it's the default


          Health metrics

          [Health metrics...] – note: this is a button which means nothing is set


          Properties

          – note: there's nothing here at all.


          JIRA

          JIRA sites [Add] – note: this is a button which means nothing is set


          Pipeline Libraries

          Sharable libraries available to any Pipeline jobs inside this folder. These libraries will be untrusted, meaning their code runs in the Groovy sandbox.

          [Add] – note: this is a button which means nothing is set


          Pipeline Model Definition

          ... this section has all empty / none defaults ...


          Automatic branch project triggering

          Branch names to build automatically: .* – note this isn't relevant



          That's the basic configuration.

          My goal is to push (see various notes about wanting to have things I can push).

          To do this, I click the Add button just above "Project Recognizers", and select Checkout Over SSH which adds an item into -- Additional  -- and then I trigger a build.

          Once I do that, I get a very fast build failure.

          Started by user ...
          19:45:35 Connecting to https://api.github.com using .../****** (... account for GitHub)
          Obtained ...Jenkinsfile from ...
          Cloning the remote Git repository
          Cloning with configured refspecs honoured and without tags
          Cloning repository https://github.com/.../....git
          ...
          Fetching upstream changes from https://github.com/.../....git
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Command "git fetch --no-tags --progress https://github.com/.../....git +refs/heads/master:refs/remotes/origin/master" returned status code 128:
          stdout: 
          stderr: remote: Invalid username or password.
          

           

          Josh Soref added a comment - The way we hit this was by using the GitHub Organization object from /view/Main/newJob . GitHub Organization Credentials User Account for GitHub (username+password) Owner (the name of the GitHub Organization) Behaviors: – Repositories – Filter by name (with wildcards) Include:  something – note: this wasn't relevant Exclude_blank_ – also not relevant – Within repository – Discover branches Strategy: Exclude branches that are also filed as PRs – note: this isn't relevant, and I think it's the default Discover pull requests from origin Strategy: Both the current pull request revision and the pull request merged with the current target branch revision – note: this isn't relevant Discover pull requests from forks Strategy: Both the current pull request revision and the pull request merged with the current target branch revision – note: this isn't relevant Trust: From users with Admin or Write permission – note: this isn't relevant, and I think it's the default – Additional – Check out to matching local branch – this shouldn't be relevant, but it's necessary for our tooling, since we're trying to automatically push tags in some cases. Project Recognizers Pipeline Jenkinsfile Script Path: slightly non-standard – note: this isn't relevant Scan Organization Triggers [x]  Periodically if not otherwise run Interval: 1 day  – note: this isn't relevant, and I think it's the default Orphaned Item Strategy [x] Discard old items – note: this isn't relevant, and I think it's the default Days to keep old items: blank – note: this isn't relevant, and I think it's the default Max # of old items to keep:  blank  – note: this isn't relevant, and I think it's the default Health metrics [Health metrics...] – note: this is a button which means nothing is set Properties – note: there's nothing here at all. JIRA JIRA sites [Add] – note: this is a button which means nothing is set Pipeline Libraries Sharable libraries available to any Pipeline jobs inside this folder. These libraries will be untrusted, meaning their code runs in the Groovy sandbox. [Add] – note: this is a button which means nothing is set Pipeline Model Definition ... this section has all empty / none defaults ... Automatic branch project triggering Branch names to build automatically: .* – note this isn't relevant That's the basic configuration. My goal is to push (see various notes about wanting to have things I can push). To do this, I click the Add button just above "Project Recognizers", and select Checkout Over SSH which adds an item into -- Additional  -- and then I trigger a build. Once I do that, I get a very fast build failure. Started by user ... 19:45:35 Connecting to https: //api.github.com using .../****** (... account for GitHub) Obtained ...Jenkinsfile from ... Cloning the remote Git repository Cloning with configured refspecs honoured and without tags Cloning repository https: //github.com/.../....git ... Fetching upstream changes from https: //github.com/.../....git ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "git fetch --no-tags --progress https: //github.com/.../....git +refs/heads/master:refs/remotes/origin/master" returned status code 128: stdout: stderr: remote: Invalid username or password.  

          john stotler added a comment -

          I'm having this same issue with Jenkins 2.121.1 and a GitHub Organization. 

          "Checkout over SSH" is set, and is configured to use a valid ssh key, but every build is still attempting to use https:

           

          stderr: remote: Password authentication is not available for Git operations.
          remote: You must use a personal access token or SSH key.

           

           

          john stotler added a comment - I'm having this same issue with Jenkins 2.121.1 and a GitHub Organization.  "Checkout over SSH" is set, and is configured to use a valid ssh key, but every build is still attempting to use https:   stderr: remote: Password authentication is not available for Git operations. remote: You must use a personal access token or SSH key.    

          Also getting this issue with Jenkins 2.121.3.

          Justin Tennant added a comment - Also getting this issue with Jenkins 2.121.3.

          We're also having this error with Jenkins 2.138 and a Github Enterprise Organization. Every checkout tries to use HTTPS even though the "Checkout over SSH" options are set at the Organization level. 

          Russell Endicott added a comment - We're also having this error with Jenkins 2.138 and a Github Enterprise Organization. Every checkout tries to use HTTPS even though the "Checkout over SSH" options are set at the Organization level. 
          Liam Newman made changes -
          Link New: This issue is related to JENKINS-46598 [ JENKINS-46598 ]

          Liam Newman added a comment -

          Submitted PR to fix in bitbucket: https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/170

          Will create one for github as well shortly. 

          Liam Newman added a comment - Submitted PR to fix in bitbucket: https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/170 Will create one for github as well shortly. 

            bitwiseman Liam Newman
            elifarley Elifarley
            Votes:
            3 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: