Skip to content

Commit

Permalink
Do not delete branches that are not created by jenkins-build-per-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
hillebrand-eleven committed Jun 25, 2015
1 parent c8e2044 commit 4cd2fc6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/groovy/com/entagen/jenkins/JenkinsJobManager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ class JenkinsJobManager {
public void deleteDeprecatedJobs(List<String> deprecatedJobNames) {
if (!deprecatedJobNames) return
deprecatedJobNames.each { String jobName ->

final def branchNameRegexMatches = jobName.matches(templateJobPrefix + branchNameRegex)
final fullBranchNameRegex = "$templateJobPrefix - $branchNameRegex"
final def branchNameRegexMatches = jobName.matches(fullBranchNameRegex)
if (!noDelete && branchNameRegexMatches) {
println "Deleting deprecated job: $jobName"
jenkinsApi.deleteJob(jobName)
} else if (!branchNameRegexMatches) {
println "Will not delete job: $jobName because it dos not comply to the branchNameRegex ${templateJobPrefix + branchNameRegex}"
println "Will not delete job: $jobName because it dos not comply to the branchNameRegex $fullBranchNameRegex"
} else {
println "Would have deleted: $jobName but noDelete is set"
}
Expand Down

0 comments on commit 4cd2fc6

Please sign in to comment.