Reformat aptly-promote-pipeline
Change-Id: I9d7b4e419bc1a296a9be63bdd55daec0ed413173
diff --git a/aptly-promote-pipeline.groovy b/aptly-promote-pipeline.groovy
index dfddfcd..b68bc81 100644
--- a/aptly-promote-pipeline.groovy
+++ b/aptly-promote-pipeline.groovy
@@ -4,16 +4,16 @@
def packages
try {
- packages = PACKAGES
+ packages = PACKAGES
} catch (MissingPropertyException e) {
- packages = ""
+ packages = ""
}
def components
try {
- components = COMPONENTS
+ components = COMPONENTS
} catch (MissingPropertyException e) {
- components = ""
+ components = ""
}
def storages
@@ -26,43 +26,43 @@
def insufficientPermissions = false
timeout(time: 12, unit: 'HOURS') {
- node("docker&&hardware") {
- try {
- stage("promote") {
- // promote is restricted to users in aptly-promote-users LDAP group
- if(jenkinsUtils.currentUserInGroups(["mcp-cicd-admins", "aptly-promote-users"])){
- lock("aptly-api") {
- for (storage in storages) {
- if (storage == "local") {
- storage = ""
- }
- retry(2){
- aptly.promotePublish(APTLY_URL, SOURCE, TARGET, RECREATE, components, packages, DIFF_ONLY, '-d --timeout 600', DUMP_PUBLISH.toBoolean(), storage)
- }
+ node("docker&&hardware") {
+ try {
+ stage("promote") {
+ // promote is restricted to users in aptly-promote-users LDAP group
+ if (jenkinsUtils.currentUserInGroups(["mcp-cicd-admins", "aptly-promote-users"])) {
+ lock("aptly-api") {
+ for (storage in storages) {
+ if (storage == "local") {
+ storage = ""
+ }
+ retry(2) {
+ aptly.promotePublish(APTLY_URL, SOURCE, TARGET, RECREATE, components, packages, DIFF_ONLY, '-d --timeout 600', DUMP_PUBLISH.toBoolean(), storage)
+ }
+ }
+ }
+ } else {
+ insufficientPermissions = true
+ throw new Exception(String.format("You don't have permissions to make aptly promote from source:%s to target:%s! Only CI/CD and QA team can perform aptly promote.", SOURCE, TARGET))
+ }
}
- }
- }else{
- insufficientPermissions = true
- throw new Exception(String.format("You don't have permissions to make aptly promote from source:%s to target:%s! Only CI/CD and QA team can perform aptly promote.", SOURCE, TARGET))
+ } catch (Throwable e) {
+ // If there was an error or exception thrown, the build failed
+ if (insufficientPermissions) {
+ currentBuild.result = "ABORTED"
+ currentBuild.description = "Promote aborted due to insufficient permissions"
+ } else {
+ currentBuild.result = "FAILURE"
+ currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
+ }
+ throw e
+ } finally {
+ if (!insufficientPermissions) {
+ common.sendNotification(currentBuild.result, "", ["slack"])
+ def _extra_descr = "${SOURCE}=>${TARGET}:\n${COMPONENTS} ${packages}"
+ currentBuild.description = currentBuild.description ? _extra_descr + " " + currentBuild.description : _extra_descr
+ }
}
- }
- } catch (Throwable e) {
- // If there was an error or exception thrown, the build failed
- if (insufficientPermissions) {
- currentBuild.result = "ABORTED"
- currentBuild.description = "Promote aborted due to insufficient permissions"
- } else {
- currentBuild.result = "FAILURE"
- currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
- }
- throw e
- } finally {
- if (!insufficientPermissions) {
- common.sendNotification(currentBuild.result,"",["slack"])
- def _extra_descr = "${SOURCE}=>${TARGET}:\n${COMPONENTS} ${packages}"
- currentBuild.description = currentBuild.description ? _extra_descr + " " + currentBuild.description : _extra_descr
- }
}
- }
}