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

Initialize GitClient credentials before decorating it with extensions

    • Icon: Story Story
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-plugin
    • None

      The GitSCMExtension decorates the GitClient first and then it set the credentials if a credentials ID is provided https://github.com/jenkinsci/git-plugin/blob/git-5.2.2/src/main/java/hudson/plugins/git/GitSCM.java#L929. This behavior was changed a long long time ago though I am not convinced it was intentional https://github.com/jenkinsci/git-plugin/commit/5bbee1ffbfbfe16441b5b5ac09bb2b32fa6fae63.

      Maybe the GitClient should be initialized first (credentials included) and GitSCMExtension at the end.

      Noticed this particular behavior when working on a bug fix for Bitbucket Branch Source that implements an interesting extension to pass the credentials ID: https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/888.v8e6d479a_1730/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/GitClientAuthenticatorExtension.java.

          [JENKINS-73677] Initialize GitClient credentials before decorating it with extensions

          markewaite I wonder if you have any opinion on this ? I can propose a PR if you think this is valid.

          Allan BURDAJEWICZ added a comment - markewaite I wonder if you have any opinion on this ? I can propose a PR if you think this is valid.

          Mark Waite added a comment -

          I am not aware of any reason that change would be harmful, but that is a change that I would want to evaluate with the plugin bill of materials and the Jenkins acceptance test harness before it is released.

          Mark Waite added a comment - I am not aware of any reason that change would be harmful, but that is a change that I would want to evaluate with the plugin bill of materials and the Jenkins acceptance test harness before it is released.

          Mark Waite added a comment -

          Reopened because the change broken the multibranch Pipelines from Bitbucket branch source when they use ssh authentication. We'll need to revisit the change without breaking existing users.

          Mark Waite added a comment - Reopened because the change broken the multibranch Pipelines from Bitbucket branch source when they use ssh authentication. We'll need to revisit the change without breaking existing users.

          Sorry about all this.. Bitbucket branch Source is actually the plugin that I was trying to fix a problem for https://issues.jenkins.io/browse/JENKINS-73471

          Allan BURDAJEWICZ added a comment - Sorry about all this.. Bitbucket branch Source is actually the plugin that I was trying to fix a problem for https://issues.jenkins.io/browse/JENKINS-73471

            allan_burdajewicz Allan BURDAJEWICZ
            allan_burdajewicz Allan BURDAJEWICZ
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: