• Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • jenkinsfile-runner
    • None
    • OS X + Docker

      When I run a Jenkinsfile that uses withCredentials, the credentials are not found, even though they exist.

      Command:

      docker run --rm -v $(pwd):/workspace -v /tmp/jenkins:/app/jenkins -v /tmp/jenkins_home/plugins:/usr/share/jenkins/ref/plugins jenkinsfile-runner

      Output:

      15.130 [id=1] WARNING j.branch.WorkspaceLocatorImpl#getWorkspaceRoot: JENKINS-2111 path sanitization ineffective when using legacy Workspace Root Directory ‘/build’; switch to ‘${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}’ as in JENKINS-8446 / JENKINS-21942
      Started
      Running in Durability level: PERFORMANCE_OPTIMIZED
      [Pipeline] Start of Pipeline
      [Pipeline] node
      Running on Jenkins in /build
      [Pipeline]

      { [Pipeline] withCredentials [Pipeline] // withCredentials [Pipeline] }

      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: Could not find credentials entry with ID 'trose'

      Jenkinsfile:

      node {
         withCredentials([ usernamePassword(credentialsId: 'trose', usernameVariable: 'user',
               passwordVariable: 'pass') ])

      {       echo "user: $user, pass: $pass"    }

      }

      From <JENKINS_HOME>/credentials.xml:

      <com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
         <scope>GLOBAL</scope>
         <id>trose</id>
         <description></description>
         <username>trose</username>
         <password>{AQAAABAAAAAQ25ldSmp9SUMhWS7u0mODZvmd+lh3ubJx0V7XCSxolTU=} </password>
      </com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
       

          [JENKINS-56816] Credentials not found by withCredentials

          Thornton Rose created issue -
          Isa Vilacides made changes -
          Assignee New: Evaristo Gutierrez [ egutierrez ]

          Hi bigtrose! Thanks for using Jenkinsfile Runner.

           

          If I am understanding correctly your reproduction steps, you are trying to provide an existing JENKINS_HOME to the Jenkinsfile Runner image so that you can use a previously configured state from the Jenkinsfile. That is not a use case that Jenkinsfile Runner is intended to be used to. However you could use the configuration-as-code plugin to automatically setup the credentials in the Jenkinsfile Runner image and be able to use them. Please check this demo for an example on how to do it.

           

          I am closing the issue. Please feel free to reopen if you consider it necessary. Thanks!

          Evaristo Gutierrez added a comment - Hi bigtrose ! Thanks for using Jenkinsfile Runner.   If I am understanding correctly your reproduction steps, you are trying to provide an existing JENKINS_HOME to the Jenkinsfile Runner image so that you can use a previously configured state from the Jenkinsfile. That is not a use case that Jenkinsfile Runner is intended to be used to. However you could use the configuration-as-code plugin to automatically setup the credentials in the Jenkinsfile Runner image and be able to use them. Please check this demo  for an example on how to do it.   I am closing the issue. Please feel free to reopen if you consider it necessary. Thanks!
          Evaristo Gutierrez made changes -
          Resolution New: Won't Fix [ 2 ]
          Status Original: Open [ 1 ] New: Fixed but Unreleased [ 10203 ]

          Thornton Rose added a comment - - edited

          I have tried withCredentials with the standalone runner (./app/target/appassembler/bin/jenkinsfile-runner ... – not in a Docker image), and it won't find credentials either. Is withCredentials just not supported? If not, how can it be added?

          Thornton Rose added a comment - - edited I have tried withCredentials with the standalone runner (./app/target/appassembler/bin/jenkinsfile-runner ... – not in a Docker image), and it won't find credentials either. Is withCredentials just not supported? If not, how can it be added?

          Thornton Rose added a comment - - edited

          File attached.

          Thornton Rose added a comment - - edited File attached.
          Thornton Rose made changes -
          Attachment New: temp.txt [ 46713 ]

          bigtrose how have you configured the credentials?

          Evaristo Gutierrez added a comment - bigtrose how have you configured the credentials?

          Thornton Rose added a comment -

          egutierrez, I configured the credentials through the UI.

          Thornton Rose added a comment - egutierrez , I configured the credentials through the UI.

          bigtrose As I tried to clarify in my previous message, Jenkinsfile Runner is not intended to re-use a previously provided JENKINS_HOME. You need to think of it as a fresh Jenkins installation and in case you want some credentials to be setup, use the Configuration As Code plugin.

          Evaristo Gutierrez added a comment - bigtrose As I tried to clarify in my previous message, Jenkinsfile Runner is not intended to re-use a previously provided JENKINS_HOME. You need to think of it as a fresh Jenkins installation and in case you want some credentials to be setup, use the Configuration As Code plugin.

            egutierrez Evaristo Gutierrez
            bigtrose Thornton Rose
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: