Compare commits
7 Commits
be5aef1bf7
...
d67feb347c
Author | SHA1 | Date | |
---|---|---|---|
d67feb347c | |||
bbe929fce2 | |||
74276d0c45 | |||
59752f6b7a | |||
180496fde6 | |||
7247dbe4a4 | |||
f08e80f131 |
24
Jenkinsfile
vendored
24
Jenkinsfile
vendored
@ -358,11 +358,15 @@ def printBranches(String repo) {
|
||||
return sh (
|
||||
label: "${repo}: branches list",
|
||||
script: """
|
||||
curl -sv -f -X 'GET' \
|
||||
HTTP_CODE=\$(curl -s -X 'GET' \
|
||||
'https://'"\$GIT_SERVER"'/api/v1/repos/${repo}/branches' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: '"\$GITEA_TOKEN" | \
|
||||
jq -r '.[] | [.name, .protected] | @tsv'
|
||||
-H 'Authorization: '"\$GITEA_TOKEN"
|
||||
-w "%{http_code}\n"
|
||||
-o output.json)
|
||||
echo \$HTTP_CODE
|
||||
cat output.json
|
||||
jq -r '.[] | [.name, .protected] | @tsv' output.json
|
||||
""",
|
||||
returnStatus: true
|
||||
) == 0
|
||||
@ -373,14 +377,14 @@ def protectBranch(String repo, String branch) {
|
||||
label: "${repo}: protect ${branch}",
|
||||
script: """
|
||||
echo '{
|
||||
"branch_name": "master"
|
||||
"branch_name": "${branch}"
|
||||
}' | \
|
||||
curl -sv -f -X 'POST' \
|
||||
curl -s -X 'POST' \
|
||||
'https://'"\$GIT_SERVER"'/api/v1/repos/${repo}/branch_protections' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: '"\$GITEA_TOKEN" \
|
||||
-H 'Authorization: token '"\$GITEA_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d -
|
||||
-d @-
|
||||
""",
|
||||
returnStatus: true
|
||||
) == 0
|
||||
@ -390,10 +394,10 @@ def unprotectBranch(String repo, String branch) {
|
||||
return sh (
|
||||
label: "${repo}: unprotect ${branch}",
|
||||
script: """
|
||||
curl -sv -f -X 'DELETE' \
|
||||
'https://'"\$GIT_SERVER"'/api/v1/repos/${repo}/branch_protections/${branch}' \
|
||||
curl -s -X 'DELETE' \
|
||||
'https://'"\$GIT_SERVER"'/api/v1/repos/${repo}/branch_protections/${URLEncoder.encode(branch)}' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: '"\$GITEA_TOKEN"
|
||||
-H 'Authorization: token '"\$GITEA_TOKEN"
|
||||
""",
|
||||
returnStatus: true
|
||||
) == 0
|
||||
|
Loading…
Reference in New Issue
Block a user