printBranches
This commit is contained in:
parent
c1a1c25528
commit
17e957bc2b
99
gitea.jenkinsfile
Normal file
99
gitea.jenkinsfile
Normal file
@ -0,0 +1,99 @@
|
||||
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'
|
||||
}
|
||||
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user