Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add possibility to start a job upon creation.

  • Loading branch information...
commit 6609bc7038d502d458dc5749e9301937a7010b3d 1 parent 53b028c
@jimmyw jimmyw authored rpmbuild committed
View
2  build.gradle
@@ -33,7 +33,7 @@ task syncWithRepo(dependsOn: 'classes', type: JavaExec) {
main = 'com.entagen.jenkins.Main'
classpath = sourceSets.main.runtimeClasspath
// pass through specified system properties to the call to main
- ['help', 'jenkinsUrl', 'jenkinsUser', 'jenkinsPassword', 'gitUrl', 'templateJobPrefix', 'templateBranchName', 'branchNameRegex', 'nestedView', 'printConfig', 'dryRun', 'noViews', 'noDelete'].each {
+ ['help', 'jenkinsUrl', 'jenkinsUser', 'jenkinsPassword', 'gitUrl', 'templateJobPrefix', 'templateBranchName', 'branchNameRegex', 'nestedView', 'printConfig', 'dryRun', 'startOnCreate', 'noViews', 'noDelete'].each {
if (System.getProperty(it)) systemProperty it, System.getProperty(it)
}
View
6 src/main/groovy/com/entagen/jenkins/JenkinsApi.groovy
@@ -61,6 +61,12 @@ class JenkinsApi {
post('job/' + missingJob.jobName + "/config.xml", missingJobConfig, [:], ContentType.XML)
}
+ /* https://192.168.4.60/hudson/job/estore-build-feature_base63_sprites/build */
+ void startJob(ConcreteJob job) {
+ println "Starting job ${job.jobName}."
+ post('job/' + job.jobName + '/build')
+ }
+
String configForMissingJob(ConcreteJob missingJob, List<TemplateJob> templateJobs) {
TemplateJob templateJob = missingJob.templateJob
String config = getJobConfig(templateJob.jobName)
View
4 src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy
@@ -15,6 +15,7 @@ class JenkinsJobManager {
Boolean dryRun = false
Boolean noViews = false
Boolean noDelete = false
+ Boolean startOnCreate = false
JenkinsApi jenkinsApi
GitApi gitApi
@@ -61,6 +62,9 @@ class JenkinsJobManager {
for(ConcreteJob missingJob in missingJobs) {
println "Creating missing job: ${missingJob.jobName} from ${missingJob.templateJob.jobName}"
jenkinsApi.cloneJobForBranch(missingJob, templateJobs)
+ if (startOnCreate) {
+ jenkinsApi.startJob(missingJob)
+ }
}
}
View
1  src/main/groovy/com/entagen/jenkins/Main.groovy
@@ -14,6 +14,7 @@ class Main {
n: [longOpt: 'nested-view', required: false, args: 1, argName: 'nestedView', description: "Nested Parent View Name - gradle flag -DnestedView=<nestedView> - optional - must have Jenkins Nested View Plugin installed"],
c: [longOpt: 'print-config', required: false, args: 0, argName: 'printConfig', description: "Check configuration - print out settings then exit - gradle flag -DprintConfig=true"],
d: [longOpt: 'dry-run', required: false, args: 0, argName: 'dryRun', description: "Dry run, don't actually modify, create, or delete any jobs, just print out what would happen - gradle flag: -DdryRun=true"],
+ s: [longOpt: 'start-on-create', required: false, args: 0, argName: 'startOnCreate', description: "When creatating a new job, start it at once."],
v: [longOpt: 'no-views', required: false, args: 0, argName: 'noViews', description: "Suppress view creation - gradle flag -DnoViews=true"],
k: [longOpt: 'no-delete', required: false, args: 0, argName: 'noDelete', description: "Do not delete (keep) branches and views - gradle flag -DnoDelete=true"],
f: [longOpt: 'filter-branch-names', required: false, args: 1, argName: 'branchNameRegex', description: "Only branches matching the regex will be accepted - gradle flag: -DbranchNameRegex=<regex>"],
Please sign in to comment.
Something went wrong with that request. Please try again.