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

SSH KEY written to wrong location

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • swarm-plugin
    • None
    • Jenkins version 2.375.2
      Swarm-Plugin 3.39
      openjdk version "11.0.18" 2023-01-17 LTS
      ID_LIKE="centos rhel fedora"
      PRETTY_NAME="Amazon Linux 2"

      Swarm node writes the `ssh-key` to the wrong location, during `checkout scm` and even the jenkins `git ....`  command.

      I'm having this Jenkinsfile in a multibranch pipeline

      node("awscli") {
          stage('checkout') {
             checkout scm
          }
      }
      

      the node labeled awscli is a linux node where the swarm jar is running.

      The swarm plugin is started with the command

      cd ./jenkins \
            && nohup java -jar ~/jenkins/swarm-client.jar \
            -url "{{ jenkins_url }}" \
            -username "{{ jenkins_admin_user }}" \
            -password "{{ jenkins_admin_password }}" \
            -labels "linux awscli" \
            -executors 2 \
            -fsroot ~/jenkins &
      

      Building this job creates this failed build console output.

       

      Started by user 
      [admin|http://10.128.1.133:8080/user/admin]
      Replayed 
      [#38|http://10.128.1.133:8080/job/tw-cbi-cloudformation/job/master/38/]
       > git rev-parse --resolve-git-dir /var/jenkins_home/caches/git-82f6c22c232fd392c58243789f8f067b/.git # timeout=10
      Setting origin to git@bitbucket.org:testwareaps/tw-cbi-cloudformation.git
       > git config remote.origin.url git@bitbucket.org:testwareaps/tw-cbi-cloudformation.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
       > git --version # 'git version 2.30.2'
       > git config --get remote.origin.url # timeout=10
      using GIT_SSH to set credentials jenkins read access key to bitbucket project
       > git fetch --tags --force --progress -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
      Seen branch in repository origin/master
      Seen branch in repository origin/release/v1.0
      Seen 2 remote branches
      Obtained Jenkinsfile from 30ea818ff5608678255eb5c1e9cbfa5fde46fa48[Pipeline] Start of Pipeline[Pipeline] nodeRunning on [ip-10-128-1-17.eu-central-1.compute.internal-0ef09621|http://10.128.1.133:8080/manage/computer/ip-10-128-1-17.eu-central-1.compute.internal-0ef09621/] in /home/ec2-user/jenkins/workspace/tw-cbi-cloudformation_master[Pipeline] {[Pipeline] stage[Pipeline] { (checkout)[Pipeline] checkoutSelected Git installation does not exist. Using Default
      The recommended git tool is: NONE
      using credential jenkins-bitbucket
      Fetching changes from the remote Git repository
      Fetching without tags
      ERROR: Error fetching remote repo 'origin'
      hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:testwareaps/tw-cbi-cloudformation.git
      	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1003)
      	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1245)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1309)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
      	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --force --progress -- git@bitbucket.org:testwareaps/tw-cbi-cloudformation.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
      stdout: 
      stderr: Warning: Identity file /home/ec2-user/jenkins/workspace/workspace/_cbi-cloudformation_release_v1.0@tmp/secretFiles/c6d88a7d-f54b-4c94-a9b6-d32218523798/ssh-key-PEM_KEY not accessible: No such file or directory.
      Permission denied (publickey).
      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2734)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2111)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:623)
      	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:158)
      	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:151)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:377)
      	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:125)
      	... 1 more
      	Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 10.128.1.17/10.128.1.17:38550
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)
      		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
      		at hudson.remoting.Channel.call(Channel.java:1000)
      		at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:143)
      		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      		at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:129)
      		at com.sun.proxy.$Proxy150.execute(Unknown Source)
      		at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1001)
      		at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1245)
      		at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1309)
      		at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
      		at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
      		at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
      		at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      		at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      		at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      		... 1 more[Pipeline] }[Pipeline] // stage[Pipeline] }[Pipeline] // node > git rev-parse --resolve-git-dir /home/ec2-user/jenkins/workspace/tw-cbi-cloudformation_master/.git # timeout=10
       > git config remote.origin.url git@bitbucket.org:testwareaps/tw-cbi-cloudformation.git # timeout=10
      Fetching upstream changes from git@bitbucket.org:testwareaps/tw-cbi-cloudformation.git
       > git --version # timeout=10
       > git --version # 'git version 2.39.1'
      using GIT_SSH to set credentials jenkins read access key to bitbucket project
       > git fetch --no-tags --force --progress -- git@bitbucket.org:testwareaps/tw-cbi-cloudformation.git +refs/heads/*:refs/remotes/origin/* # timeout=10[Pipeline] End of PipelineERROR: Error fetching remote repo 'origin'
      Finished: FAILURE
      

      Looking at the output, then I'm building the master branch of the project, but the swarm plugin tries to write the SSH_KEY to 
       

      Identity file /home/ec2-user/jenkins/workspace/workspace/_cbi-cloudformation_release_v1.0@tmp/secretFiles/c6d88a7d-f54b-4c94-a9b6-d32218523798/ssh-key-PEM_KEY
      

      But it should have been:

      /home/ec2-user/jenkins/workspace/tw-cbi-cloudformation_master@tmp/....
      

      which we can see in the console output that it is running on

      Running on ip-10-128-1-17.eu-central-1.compute.internal-0ef09621 in /home/ec2-user/jenkins/workspace/tw-cbi-cloudformation_master
      

      When running the job against a fixed jenkins agent, there is no problems.

            Unassigned Unassigned
            jakobojvind Jakob Øjvind Nielsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: