Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
5eea922d30 | |||
501e12abbe | |||
17e957bc2b |
121
gitea.jenkinsfile
Normal file
121
gitea.jenkinsfile
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
label 'branch_manager'
|
||||||
|
}
|
||||||
|
environment {
|
||||||
|
GIT_SERVER = 'git.onlyoffice.com'
|
||||||
|
GIT_OWNER = 'ONLYOFFICE'
|
||||||
|
GITEA_TOKEN = credentials('gitea-token')
|
||||||
|
}
|
||||||
|
options {
|
||||||
|
disableConcurrentBuilds()
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Branch Manager') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
stats = [repos: [:]]
|
||||||
|
String branch = env.BRANCH_NAME
|
||||||
|
ArrayList baseBranches = []
|
||||||
|
getRepos().each {
|
||||||
|
stats.repos.put(it, [:])
|
||||||
|
}
|
||||||
|
Boolean pAction
|
||||||
|
Boolean sAction
|
||||||
|
|
||||||
|
// printBranches
|
||||||
|
// stats.repos.each { repo, status ->
|
||||||
|
// pAction = printBranches(repo)
|
||||||
|
// status.primary = (pAction) ? 'success' : 'failure'
|
||||||
|
// }
|
||||||
|
|
||||||
|
//printBranchProtection
|
||||||
|
stats.repos.each { repo, status ->
|
||||||
|
pAction = printBranchProtection(repo)
|
||||||
|
status.primary = (pAction) ? 'success' : 'failure'
|
||||||
|
}
|
||||||
|
|
||||||
|
stats.putAll([
|
||||||
|
branch: branch,
|
||||||
|
baseBranches: baseBranches,
|
||||||
|
success: stats.repos.findAll { repo, status ->
|
||||||
|
status.primary in ['skip', 'success']
|
||||||
|
}.size(),
|
||||||
|
total: stats.repos.size()
|
||||||
|
])
|
||||||
|
println stats
|
||||||
|
|
||||||
|
String text = ''
|
||||||
|
text += "${stats.success}/${stats.total}"
|
||||||
|
stats.repos.each { repo, status ->
|
||||||
|
text += '\n'
|
||||||
|
switch(status.primary) {
|
||||||
|
case 'skip': text += '🔘'; break
|
||||||
|
case 'success': text += '☑️'; break
|
||||||
|
case 'failure': text += '🚫'; break
|
||||||
|
default: text += '➖'
|
||||||
|
}
|
||||||
|
text += " ${repo}"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getRepos() {
|
||||||
|
return [
|
||||||
|
'build_tools',
|
||||||
|
'core',
|
||||||
|
'desktop-apps',
|
||||||
|
'desktop-sdk',
|
||||||
|
'document-builder-package',
|
||||||
|
'document-server-package',
|
||||||
|
'documents-pipeline',
|
||||||
|
'onlyoffice',
|
||||||
|
'sdkjs',
|
||||||
|
'sdkjs-forms',
|
||||||
|
'sdkjs-ooxml',
|
||||||
|
'server',
|
||||||
|
'server-license',
|
||||||
|
'server-lockstorage',
|
||||||
|
'web-apps',
|
||||||
|
'web-apps-mobile',
|
||||||
|
'Docker-DocumentServer',
|
||||||
|
'DocumentBuilder'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
def printBranches(String repo) {
|
||||||
|
return sh (
|
||||||
|
label: "${repo}: branches list",
|
||||||
|
script: """
|
||||||
|
HTTP_CODE=\$(curl -s -X 'GET' \
|
||||||
|
https://\$GIT_SERVER/api/v1/repos/\$GIT_OWNER/${repo}/branches \
|
||||||
|
-H 'Authorization: token '\$GITEA_TOKEN \
|
||||||
|
-w %{http_code} \
|
||||||
|
-o output.json)
|
||||||
|
test \$HTTP_CODE -eq 200
|
||||||
|
jq -r '.[] | [.name, .protected] | @tsv' output.json
|
||||||
|
""",
|
||||||
|
returnStatus: true
|
||||||
|
) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
def printBranchProtection(String repo) {
|
||||||
|
return sh (
|
||||||
|
label: "${repo}: branch protection list",
|
||||||
|
script: """
|
||||||
|
HTTP_CODE=\$(curl -s -X 'GET' \
|
||||||
|
https://\$GIT_SERVER/api/v1/repos/\$GIT_OWNER/${repo}/branch_protections \
|
||||||
|
-H 'Authorization: token '\$GITEA_TOKEN \
|
||||||
|
-w %{http_code} \
|
||||||
|
-o output.json)
|
||||||
|
test \$HTTP_CODE -eq 200
|
||||||
|
jq -r '.[] | [.branch_name] | @tsv' output.json
|
||||||
|
""",
|
||||||
|
returnStatus: true
|
||||||
|
) == 0
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user