From 751081e05ee4580cb844edd39c31b9c3b4a02c35 Mon Sep 17 00:00:00 2001 From: Andrei Neculau Date: Sat, 1 Aug 2015 14:39:50 +0200 Subject: [PATCH] no double negation --- README.md | 4 ---- build.gradle | 2 +- .../com/entagen/jenkins/JenkinsJobManager.groovy | 10 +++++----- src/main/groovy/com/entagen/jenkins/Main.groovy | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 516ef76e..0183ec89 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,6 @@ All available **Switches** can be found in the source-code [here](src/main/groov I currently use something like this ``` --DnoDelete=true --DnoViews=true -DjenkinsUrl=https://example.com/jenkins -DallowSelfsignedSslCerts=true -DgitUrl=git@example.com:repo.git @@ -47,8 +45,6 @@ I currently use something like this **NOTE**: `testing-my-repo-Xbranch-sync-with-repo` is disabled, but has cronjob builder/poller, so that the new jobs based on it, will be enabled and will start on their own. -**NOTE**: if you use this for branches that eventually get deleted, and you would like `jenkins-build-per-branch` to delete jobs for those pruned branches set `noDelete=false` AND MAKE SURE TO RENAME `testing-my-repo-Xbranch-sync-with-repo` to e.g. `sync-with-repo-testing-my-repo-Xbranch`, or else it will think `Xbranch-sync-with-repo` is a branch that doesn't exist anymore. - ## Original docs [README.original.md](README.original.md) diff --git a/build.gradle b/build.gradle index 62b47829..daa017ba 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,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', 'viewRegex', 'printConfig', 'dryRun', 'startOnCreate', 'noViews', 'noDelete', 'allowSelfsignedSslCerts', 'enableJobRegex', 'disableJobRegex'].each { + ['help', 'jenkinsUrl', 'jenkinsUser', 'jenkinsPassword', 'gitUrl', 'templateJobPrefix', 'templateBranchName', 'branchNameRegex', 'nestedView', 'viewRegex', 'printConfig', 'dryRun', 'startOnCreate', 'views', 'deleteOld', 'allowSelfsignedSslCerts', 'enableJobRegex', 'disableJobRegex'].each { if (System.getProperty(it)) systemProperty it, System.getProperty(it) } diff --git a/src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy b/src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy index b051813e..d1e808c1 100644 --- a/src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy +++ b/src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy @@ -16,8 +16,8 @@ class JenkinsJobManager { Boolean allowSelfsignedSslCerts = false Boolean dryRun = false - Boolean noViews = false - Boolean noDelete = false + Boolean views = false + Boolean deleteOld = false JenkinsApi jenkinsApi GitApi gitApi @@ -41,7 +41,7 @@ class JenkinsJobManager { syncJobs(allBranchNames, allJobNames, templateJobs) // create any missing branch views, scoped within a nested view if we were given one - if (!noViews) { + if (views) { syncViews(allBranchNames) } } @@ -52,7 +52,7 @@ class JenkinsJobManager { List expectedJobs = this.expectedJobs(templateJobs, nonTemplateBranchNames) createMissingJobs(expectedJobs, currentTemplateDrivenJobNames, templateJobs) - if (!noDelete) { + if (deleteOld) { deleteDeprecatedJobs(currentTemplateDrivenJobNames - expectedJobs.jobName) } } @@ -117,7 +117,7 @@ class JenkinsJobManager { List missingBranchViews = expectedBranchViews.findAll { BranchView branchView -> !existingViewNames.contains(branchView.viewName)} addMissingViews(missingBranchViews) - if (!noDelete) { + if (deleteOld) { List deprecatedViewNames = getDeprecatedViewNames(existingViewNames, expectedBranchViews) deleteDeprecatedViews(deprecatedViewNames) } diff --git a/src/main/groovy/com/entagen/jenkins/Main.groovy b/src/main/groovy/com/entagen/jenkins/Main.groovy index 803f9dce..4150d772 100644 --- a/src/main/groovy/com/entagen/jenkins/Main.groovy +++ b/src/main/groovy/com/entagen/jenkins/Main.groovy @@ -15,9 +15,9 @@ class Main { c: [longOpt: 'print-config', required: false, args: 0, argName: 'printConfig', description: "Check configuration - print out settings then exit"], 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"], s: [longOpt: 'start-on-create', required: false, args: 0, argName: 'startOnCreate', description: "When creating 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"], + v: [longOpt: 'views', required: false, args: 0, argName: 'views', description: "Create views"], r: [longOpt: 'view-regex', required: false, args: 1, argName: 'viewRegex', description: "Supply a custom regex to be applied to any generated views, overriding the default template regex"], + k: [longOpt: 'delete-old', required: false, args: 0, argName: 'deleteOld', description: "Delete old branches and views"], f: [longOpt: 'filter-branch-names', required: false, args: 1, argName: 'branchNameRegex', description: "Only branches matching the regex will be accepted"], en: [longOpt: 'enable-job-regex', required: false, args: 1, argName: 'enableJobRegex', description: "If job matches regex, enable job no matter status of template job"], dis: [longOpt: 'disable-job-regex', required: false, args: 1, argName: 'disableJobRegex', description: "If job matches regex, disable job no matter status of template job"],