Compare commits

..

7 Commits

Author SHA1 Message Date
d67feb347c BM8 2024-09-11 18:01:22 +03:00
bbe929fce2 BM7 2024-09-11 17:48:29 +03:00
74276d0c45 BM6 2024-09-11 17:45:44 +03:00
59752f6b7a BM5 2024-09-11 17:42:14 +03:00
180496fde6 BM4 2024-09-11 17:37:33 +03:00
7247dbe4a4 BM3 2024-09-11 17:35:30 +03:00
f08e80f131 BM2 2024-09-11 17:29:39 +03:00

24
Jenkinsfile vendored
View File

@ -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