Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'rvaughn/delete-option'
Browse files Browse the repository at this point in the history
Conflicts:
	build.gradle
	src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy
	src/main/groovy/com/entagen/jenkins/Main.groovy
  • Loading branch information
tednaleid committed Aug 2, 2012
2 parents 11937dc + d1b0a5c commit 96bb98e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -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'].each {
['help', 'jenkinsUrl', 'jenkinsUser', 'jenkinsPassword', 'gitUrl', 'templateJobPrefix', 'templateBranchName', 'branchNameRegex', 'nestedView', 'printConfig', 'dryRun', 'noViews', 'noDelete'].each {
if (System.getProperty(it)) systemProperty it, System.getProperty(it)
}

Expand Down
11 changes: 8 additions & 3 deletions src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy
Expand Up @@ -14,6 +14,7 @@ class JenkinsJobManager {

Boolean dryRun = false
Boolean noViews = false
Boolean noDelete = false

JenkinsApi jenkinsApi
GitApi gitApi
Expand Down Expand Up @@ -48,7 +49,9 @@ class JenkinsJobManager {
List<ConcreteJob> expectedJobs = this.expectedJobs(templateJobs, nonTemplateBranchNames)

createMissingJobs(expectedJobs, currentTemplateDrivenJobNames, templateJobs)
deleteDeprecatedJobs(currentTemplateDrivenJobNames - expectedJobs.jobName)
if (!noDelete) {
deleteDeprecatedJobs(currentTemplateDrivenJobNames - expectedJobs.jobName)
}
}

public void createMissingJobs(List<ConcreteJob> expectedJobs, List<String> currentJobs, List<TemplateJob> templateJobs) {
Expand Down Expand Up @@ -108,8 +111,10 @@ class JenkinsJobManager {
List<BranchView> missingBranchViews = expectedBranchViews.findAll { BranchView branchView -> !existingViewNames.contains(branchView.viewName)}
addMissingViews(missingBranchViews)

List<String> deprecatedViewNames = getDeprecatedViewNames(existingViewNames, expectedBranchViews)
deleteDeprecatedViews(deprecatedViewNames)
if (!noDelete) {
List<String> deprecatedViewNames = getDeprecatedViewNames(existingViewNames, expectedBranchViews)
deleteDeprecatedViews(deprecatedViewNames)
}
}

public void addMissingViews(List<BranchView> missingViews) {
Expand Down
1 change: 1 addition & 0 deletions src/main/groovy/com/entagen/jenkins/Main.groovy
Expand Up @@ -15,6 +15,7 @@ class Main {
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"],
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>"],
usr: [longOpt: 'jenkins-user', required: false, args: 1, argName: 'jenkinsUser', description: "Jenkins username - gradle flag -DjenkinsUser=<jenkinsUser>"],
pwd: [longOpt: 'jenkins-password', required: false, args: 1, argName: 'jenkinsPassword', description: "Jenkins password - gradle flag -DjenkinsPassword=<jenkinsPassword>"]
Expand Down

0 comments on commit 96bb98e

Please sign in to comment.