From 592717427895a8fcb37e8936d6728ad66bebc777 Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Wed, 11 Sep 2024 18:29:49 +0300 Subject: [PATCH] BM4 --- Jenkinsfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f96bfc2..918295f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -361,7 +361,7 @@ def printBranches(String repo) { script: """ HTTP_CODE=\$(curl -s -X 'GET' \ 'https://'"\$GIT_SERVER"'/api/v1/repos/${repo}/branches' \ - -H 'Authorization: '"\$GITEA_TOKEN" \ + -H 'Authorization: token '"\$GITEA_TOKEN" \ -w '%{http_code}' \ -o output.json) test \$HTTP_CODE -eq 200 @@ -375,13 +375,17 @@ def protectBranch(String repo, String branch) { return sh ( label: "${repo}: protect ${branch}", script: """ - echo '{ + HTTP_CODE=\$(echo '{ "branch_name": "${branch}" }' | \ curl -s -X 'POST' \ 'https://'"\$GIT_SERVER"'/api/v1/repos/${repo}/branch_protections' \ -H 'Authorization: token '"\$GITEA_TOKEN" \ - -d @- + -w '%{http_code}' \ + -o output.json \ + -d @-) + test \$HTTP_CODE -eq 201 + jq '.' output.json """, returnStatus: true ) == 0