Running into issues checking out a private repository within a slave
container.
To start, I created a SSH username + private key credential. The private
key has been verified to work against the GitHub organization I am
attempting to clone repositories from.
My pipeline looks like such:
import groovy.json.JsonSlurper
@NonCPS
def parseResponse(response) {
def list = new JsonSlurper().parseText( response )
def repositories = []
for (Map item : list) {
repositories.push(item.ssh_url)
//println "${item.ssh_url}"
}
return repositories
}
podTemplate(label: 'mypod', containers: [
containerTemplate(name: 'golang', image: 'golang:1.6.3', ttyEnabled:
true, command: 'cat')
]) {
node ('mypod') {
stage 'Find Repositories'
// make call to GitHub API to list all repositories for project
def response = httpRequest
"https://api.github.com/teams/xxxx/repos?access_token=xxxxx"
// parse the response and write out a file containing the list of
repositories
def repositories = parseResponse(response.content)
container('golang') {
stage 'Checkout Repositories'
for (String item : repositories) {
git branch: 'master', credentialsId:
'7f66557f-8ee3-4d69-b271-f8b1bbfa02b0', url: item
println item
}
sh """
sleep 600
"""
}
}
}
Basically, I query all the repositories that are part of a team and then
want to loop over those and perform some action. But the git call fails
with the following:
[Pipeline] gitCloning the remote Git repository
Cloning repository [email protected]:XXXXX/activeMqMessageQueueing.git
> git init /home/jenkins/workspace/DevOps/git-hooks # timeout=10
Fetching upstream changes from
[email protected]:XXXXXX/activeMqMessageQueueing.git
> git --version # timeout=10
using GIT_SSH to set credentials s-automation GitHub SSH key
> git fetch --tags --progress
> [email protected]:XXXXX/activeMqMessageQueueing.git
> +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'hudson.plugins.git.GitException
<http://stacktrace.jenkins-ci.org/search?query=hudson.plugins.git.GitException>:
Command "git fetch --tags --progress
[email protected]:XXXX/activeMqMessageQueueing.git
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: /tmp/ssh7121108186801417889.sh: line 6: ssh: not found
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So it appears to set the credentials correctly (using GIT_SSH to set
credentials to s-automation GitHub SSH key) but then complains SSH not
found. The container that this part of the pipeline runs in has SSH so not
sure why it would complain about that. I would love to be able to see what
is in /tmp/ssh7121108186801417889.sh but the job fails and the container
dies at that point.
Kind of stuck where to go from here. Any assistance would be appreciated.
Thanks
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/d911f54f-149b-42d2-94ed-d1f4a94e2d37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.