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

Git scm.userRemoteConfigs.credentialsId configured by Bitbucket is null

    • 933.2.0

      Jenkins and plugins versions report

      Environment
      Jenkins: 2.452.2
      OS: Linux - 6.5.0-1020-aws
      Java: 17.0.11 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

      What Operating System are you using (both controller, and any agents involved in the problem)?

      Linux - 6.5.0-1020-aws on kubernetes

      Reproduction steps

      We have some steps in our jenkins pipelines that use the credentials provided for the checkout for other git actions.
      Therefor we use some credentials binding
      withCredentials([usernamePassword( credentialsId: scm.userRemoteConfigs[0].credentialsId, usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD' )])

      This works with versions of these plugin previous to 887

      Expected Results

      scm.userRemoteConfigs[0].credentialsId returns the credentials id

      Actual Results

      Jenkins build breaks with:

      {{09:34:41 java.lang.NullPointerException
      09:34:41 at java.base/java.util.Objects.requireNonNull(Unknown Source)
      09:34:41 at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:897)
      09:34:41 at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:866)
      09:34:41 at org.jenkinsci.plugins.credentialsbinding.MultiBinding.getCredentials(MultiBinding.java:195)
      09:34:41 at org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding.bind(UsernamePasswordMultiBinding.java:73)
      09:34:41 at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Execution2.doStart(BindingStep.java:132)
      09:34:41 at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
      09:34:41 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      09:34:41 at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
      09:34:41 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      09:34:41 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      09:34:41 at java.base/java.lang.Thread.run(Unknown Source)}}

      Anything else?

      I think this was very likely introduced by the security fix ad359b3

      Is this a bug or is it the intended behaviour?

          [JENKINS-73471] Git scm.userRemoteConfigs.credentialsId configured by Bitbucket is null

          Niklas created issue -

          Allan BURDAJEWICZ added a comment - - edited

          A workaround could be to retrieve the credentials from the extension that was introduced..

          scm.extensions.find { ext -> ext instanceof com.cloudbees.jenkins.plugins.bitbucket.GitClientAuthenticatorExtension}?.credentials?.id
          

          Allan BURDAJEWICZ added a comment - - edited A workaround could be to retrieve the credentials from the extension that was introduced.. scm.extensions.find { ext -> ext instanceof com.cloudbees.jenkins.plugins.bitbucket.GitClientAuthenticatorExtension}?.credentials?.id
          Allan BURDAJEWICZ made changes -
          Link New: This issue is blocked by JENKINS-73797 [ JENKINS-73797 ]
          Allan BURDAJEWICZ made changes -
          Link Original: This issue is blocked by JENKINS-73797 [ JENKINS-73797 ]
          Allan BURDAJEWICZ made changes -
          Link New: This issue is blocked by JENKINS-73677 [ JENKINS-73677 ]

          Attempt to solve the problem by restoring credentials caused https://issues.jenkins.io/browse/JENKINS-73797.. Need to have more test coverage around SSHCheckoutTrait.

          Allan BURDAJEWICZ added a comment - Attempt to solve the problem by restoring credentials caused https://issues.jenkins.io/browse/JENKINS-73797 .. Need to have more test coverage around SSHCheckoutTrait.
          Nikolas Falco made changes -
          Summary Original: Version 887 breaks usage of scm.userRemoteConfigs[].credentialsId New: Git scm.userRemoteConfigs.credentialsId configured by Bitbucket is null
          Nikolas Falco made changes -
          Assignee New: Nikolas Falco [ nfalco ]
          Nikolas Falco made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Allan BURDAJEWICZ made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

            nfalco Nikolas Falco
            twostone Niklas
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: