This commit is contained in:
Semyon Bezrukov 2024-09-12 14:29:31 +03:00
parent 3692781bb6
commit 7f72daf054

39
Jenkinsfile vendored
View File

@ -55,7 +55,7 @@ pipeline {
)
booleanParam (
name: 'protect_branch',
description: 'Protect branch (for start only)',
description: 'Protect branch (for start & rename only)',
defaultValue: defaults.protect_branch
)
string (
@ -96,7 +96,6 @@ pipeline {
stats.repos.each { repo, status ->
pAction = printBranches(repo)
status.primary = (pAction) ? 'success' : 'failure'
status.secondary = 'none'
}
} else if (params.action_type == 'start') {
@ -120,9 +119,13 @@ pipeline {
}
}
if (params.protect_branch && !repo.contains('documents-pipeline')) {
sAction = protectBranch(repo, branch)
status.secondary = (sAction) ? 'lock' : ''
if (params.protect_branch) {
if (!repo.contains('documents-pipeline')) {
sAction = protectBranch(repo, branch)
} else {
sAction = false
}
status.secondary = (sAction) ? 'lock' : 'none'
}
}
@ -159,9 +162,13 @@ pipeline {
unprotectBranch(repo, branch)
pAction = mergeBranch(repo, branch, baseBranches)
status.primary = (pAction) ? 'success' : 'failure'
if (pAction && !repo.contains('documents-pipeline')) {
sAction = deleteBranch(repo, branch)
status.secondary = (sAction) ? 'delete' : ''
if (pAction) {
if (!repo.contains('documents-pipeline')) {
sAction = deleteBranch(repo, branch)
} else {
sAction = false
}
status.secondary = (sAction) ? 'delete' : 'none'
}
}
}
@ -184,9 +191,13 @@ pipeline {
if (pAction) {
unprotectBranch(repo, env.BRANCH_NAME)
deleteBranch(repo, env.BRANCH_NAME)
if (params.protect_branch && !repo.contains('documents-pipeline')) {
sAction = protectBranch(repo, branch)
status.secondary = (sAction) ? 'lock' : ''
if (params.protect_branch) {
if (!repo.contains('documents-pipeline')) {
sAction = protectBranch(repo, branch)
} else {
sAction = false
}
status.secondary = (sAction) ? 'lock' : 'none'
}
}
}
@ -216,7 +227,6 @@ pipeline {
stats.repos.each { repo, status ->
pAction = protectBranch(repo, branch)
status.primary = (pAction) ? 'success' : 'failure'
status.secondary = 'none'
}
} else if (params.action_type == 'unprotect') {
@ -224,7 +234,6 @@ pipeline {
stats.repos.each { repo, status ->
pAction = unprotectBranch(repo, branch)
status.primary = (pAction) ? 'success' : 'failure'
status.secondary = 'none'
}
}
@ -443,8 +452,8 @@ def sendNotification() {
switch(status.secondary) {
case 'lock': text += '🔒'; break
case 'delete': text += '♻️'; break
case 'none': text += ''; break
default: text += ''
case 'none': text += ''; break
default: text += ''
}
text += " [${repo}](https://${env.GIT_SERVER}/${repo})"
}