import groovy.json.JsonSlurper
@NonCPSdef 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 """ }
}}[Pipeline] git
Cloning the remote Git repository
Cloning repository g...@github.com:XXXXX/activeMqMessageQueueing.git
> git init /home/jenkins/workspace/DevOps/git-hooks # timeout=10
Fetching upstream changes from g...@github.com:XXXXXX/activeMqMessageQueueing.git
> git --version # timeout=10
using GIT_SSH to set credentials s-automation GitHub SSH key
> git fetch --tags --progress g...@github.com:XXXXX/activeMqMessageQueueing.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress g...@github.com: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.