Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
606553a1
Commit
606553a1
authored
Mar 11, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete unused CI helper functions
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
e8f231fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
94 deletions
+0
-94
scripts/utils.sh
scripts/utils.sh
+0
-94
No files found.
scripts/utils.sh
View file @
606553a1
...
@@ -57,97 +57,3 @@ function echoinfo() {
...
@@ -57,97 +57,3 @@ function echoinfo() {
printf
"
\0
33[0;33m%s
\n\0
33[0m"
"
${
1
}
"
>
&2
;
printf
"
\0
33[0;33m%s
\n\0
33[0m"
"
${
1
}
"
>
&2
;
fi
fi
}
}
function
get_job_id
()
{
local
job_name
=
"
${
1
}
"
local
query_string
=
"
${
2
:+&
${
2
}}
"
local
api_token
=
"
${
API_TOKEN
-
${
GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN
}}
"
if
[
-z
"
${
api_token
}
"
]
;
then
echoerr
"Please provide an API token with
\$
API_TOKEN or
\$
GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN."
return
fi
local
max_page
=
3
local
page
=
1
while
true
;
do
local
url
=
"https://gitlab.com/api/v4/projects/
${
CI_PROJECT_ID
}
/pipelines/
${
CI_PIPELINE_ID
}
/jobs?per_page=100&page=
${
page
}${
query_string
}
"
echoinfo
"GET
${
url
}
"
local
job_id
job_id
=
$(
curl
--silent
--show-error
--header
"PRIVATE-TOKEN:
${
api_token
}
"
"
${
url
}
"
| jq
"map(select(.name ==
\"
${
job_name
}
\"
)) | map(.id) | last"
)
[[
"
${
job_id
}
"
==
"null"
&&
"
${
page
}
"
-lt
"
$max_page
"
]]
||
break
let
"page++"
done
if
[[
"
${
job_id
}
"
==
""
]]
;
then
echoerr
"The '
${
job_name
}
' job ID couldn't be retrieved!"
else
echoinfo
"The '
${
job_name
}
' job ID is
${
job_id
}
"
echo
"
${
job_id
}
"
fi
}
function
play_job
()
{
local
job_name
=
"
${
1
}
"
local
job_id
job_id
=
$(
get_job_id
"
${
job_name
}
"
"scope=manual"
)
;
if
[
-z
"
${
job_id
}
"
]
;
then return
;
fi
local
api_token
=
"
${
API_TOKEN
-
${
GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN
}}
"
if
[
-z
"
${
api_token
}
"
]
;
then
echoerr
"Please provide an API token with
\$
API_TOKEN or
\$
GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN."
return
fi
local
url
=
"https://gitlab.com/api/v4/projects/
${
CI_PROJECT_ID
}
/jobs/
${
job_id
}
/play"
echoinfo
"POST
${
url
}
"
local
job_url
job_url
=
$(
curl
--silent
--show-error
--request
POST
--header
"PRIVATE-TOKEN:
${
api_token
}
"
"
${
url
}
"
| jq
".web_url"
)
echoinfo
"Manual job '
${
job_name
}
' started at:
${
job_url
}
"
}
function
wait_for_job_to_be_done
()
{
local
job_name
=
"
${
1
}
"
local
query_string
=
"
${
2
}
"
local
job_id
job_id
=
$(
get_job_id
"
${
job_name
}
"
"
${
query_string
}
"
)
if
[
-z
"
${
job_id
}
"
]
;
then return
;
fi
local
api_token
=
"
${
API_TOKEN
-
${
GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN
}}
"
if
[
-z
"
${
api_token
}
"
]
;
then
echoerr
"Please provide an API token with
\$
API_TOKEN or
\$
GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN."
return
fi
echoinfo
"Waiting for the '
${
job_name
}
' job to finish..."
local
url
=
"https://gitlab.com/api/v4/projects/
${
CI_PROJECT_ID
}
/jobs/
${
job_id
}
"
echoinfo
"GET
${
url
}
"
# In case the job hasn't finished yet. Keep trying until the job times out.
local
interval
=
30
local
elapsed_seconds
=
0
while
true
;
do
local
job_status
job_status
=
$(
curl
--silent
--show-error
--header
"PRIVATE-TOKEN:
${
api_token
}
"
"
${
url
}
"
| jq
".status"
|
sed
-e
s/
\"
//g
)
[[
"
${
job_status
}
"
==
"pending"
||
"
${
job_status
}
"
==
"running"
]]
||
break
printf
"."
let
"elapsed_seconds+=interval"
sleep
${
interval
}
done
local
elapsed_minutes
=
$((
elapsed_seconds
/
60
))
echoinfo
"Waited '
${
job_name
}
' for
${
elapsed_minutes
}
minutes."
if
[[
"
${
job_status
}
"
==
"failed"
]]
;
then
echoerr
"The '
${
job_name
}
' failed."
elif
[[
"
${
job_status
}
"
==
"manual"
]]
;
then
echoinfo
"The '
${
job_name
}
' is manual."
else
echoinfo
"The '
${
job_name
}
' passed."
fi
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment