|
|
@@ -5,7 +5,6 @@ def api = "${server}/api/v1"
|
|
|
def restExists(url) {
|
|
|
def u = new URL(url)
|
|
|
def req = u.openConnection();
|
|
|
- req.setRequestMethod("OPTIONS")
|
|
|
def getRC = req.getResponseCode();
|
|
|
if(getRC.equals(200)) {
|
|
|
return true;
|
|
|
@@ -22,8 +21,36 @@ def projects = restJSONGet("${api}/user/repos?token=${apikey}")
|
|
|
|
|
|
projects.each {
|
|
|
def project = it.full_name
|
|
|
+ def repo = it.clone_url
|
|
|
def branchName = "docker"
|
|
|
def jenkinsFile = restExists("${api}/repos/${project}/raw/${branchName}/Jenkinsfile?token=${apikey}")
|
|
|
- def jobName = "${project}".replaceAll('/','-')
|
|
|
- println("${project}/${branchName} - ${jobName} / hasFile ${jenkinsFile}")
|
|
|
+ def jobName = "${JOB_PREFIX}${project}".replaceAll('/','-')
|
|
|
+ if (jenkinsFile) {
|
|
|
+ pipelineJob(jobName) {
|
|
|
+ triggers {
|
|
|
+ scm('@hourly')
|
|
|
+ }
|
|
|
+ description("Pipeline for $repo")
|
|
|
+ quietPeriod(5*60)
|
|
|
+ environmentVariables(FOO: 'bar', TEST: '123')
|
|
|
+ definition {
|
|
|
+ cpsScm {
|
|
|
+ scm {
|
|
|
+ git {
|
|
|
+ remote {
|
|
|
+ url(repo)
|
|
|
+ credentials(GOGS_CREDENTIALS)
|
|
|
+ }
|
|
|
+ branches('master', '**/feature*')
|
|
|
+ scriptPath('Jenkinsfile')
|
|
|
+ extensions { } // required as otherwise it may try to tag the repo, which you may not want
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wrappers {
|
|
|
+ buildName('#${BUILD_NUMBER} on ${ENV,var="BRANCH"}')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|