Last active
September 22, 2015 08:55
-
-
Save davidpelayo/de4181e93584df7443c9 to your computer and use it in GitHub Desktop.
Jobs generator based on forks of a certain github repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//thanks to https://gist.github.com/joshareed/5706061 | |
import groovy.json.JsonSlurper | |
def owner = "<owner>" | |
def project = "<project>" | |
// curl -k -u <user>:<token> -X GET https://api.github.com/repos/<owner>/<repo>/forks > forks.txt | |
def fetch(addr, params = [:]) { | |
def auth = "<personalAPIToken>" // see https://github.com/blog/1509-personal-api-tokens | |
def json = new JsonSlurper() | |
return json.parse(addr.toURL().newReader(requestProperties: ["Authorization": "token ${auth}".toString(), "Accept": "application/json"])) | |
} | |
def forks = fetch("https://api.github.com/repos/${owner}/${project}/forks") | |
forks.each { | |
def fork = it.full_name | |
def name = it.owner.login | |
def jobName = "${project}-${name}".replaceAll('/','-') | |
job(jobName) { | |
scm { | |
git { | |
remote { | |
github(fork, 'https') | |
credentials('<idCredentials>') | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment