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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
64a738c0
Commit
64a738c0
authored
Jan 24, 2019
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce echoinfo for information
parent
a59563a1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
scripts/review_apps/review-apps.sh
scripts/review_apps/review-apps.sh
+14
-13
No files found.
scripts/review_apps/review-apps.sh
View file @
64a738c0
...
...
@@ -2,6 +2,7 @@
export
TILLER_NAMESPACE
=
"
$KUBE_NAMESPACE
"
function
echoerr
()
{
printf
"
\0
33[0;31m%s
\n\0
33[0m"
"
$*
"
>
&2
;
}
function
echoinfo
()
{
printf
"
\0
33[0;33m%s
\n\0
33[0m"
"
$*
"
>
&2
;
}
function
check_kube_domain
()
{
if
[
-z
${
REVIEW_APPS_DOMAIN
+x
}
]
;
then
...
...
@@ -238,17 +239,17 @@ function get_pod() {
local
app_name
=
"
${
1
}
"
local
status
=
"
${
2
-Running
}
"
get_pod_cmd
=
"kubectl get pods -n
${
KUBE_NAMESPACE
}
--field-selector=status.phase=
${
status
}
-lapp=
${
app_name
}
,release=
${
CI_ENVIRONMENT_SLUG
}
--no-headers -o=custom-columns=NAME:.metadata.name"
echo
err
"Running '
${
get_pod_cmd
}
'"
echo
info
"Running '
${
get_pod_cmd
}
'"
while
true
;
do
local
pod_name
=
"
$(
eval
$get_pod_cmd
)
"
[[
"
${
pod_name
}
"
==
""
]]
||
break
echo
err
"Waiting till '
${
app_name
}
' pod is ready"
;
echo
info
"Waiting till '
${
app_name
}
' pod is ready"
;
sleep
5
;
done
echo
err
"The pod name is '
${
pod_name
}
'."
echo
info
"The pod name is '
${
pod_name
}
'."
echo
"
${
pod_name
}
"
}
...
...
@@ -290,7 +291,7 @@ function get_job_id() {
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
}
"
echo
err
"GET
${
url
}
"
echo
info
"GET
${
url
}
"
local
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
...
...
@@ -301,7 +302,7 @@ function get_job_id() {
if
[[
"
${
job_id
}
"
==
""
]]
;
then
echoerr
"The '
${
job_name
}
' job ID couldn't be retrieved!"
else
echo
err
"The '
${
job_name
}
' job ID is
${
job_id
}
"
echo
info
"The '
${
job_name
}
' job ID is
${
job_id
}
"
echo
"
${
job_id
}
"
fi
}
...
...
@@ -312,10 +313,10 @@ function play_job() {
if
[
-z
"
${
job_id
}
"
]
;
then return
;
fi
local
url
=
"https://gitlab.com/api/v4/projects/
${
CI_PROJECT_ID
}
/jobs/
${
job_id
}
/play"
echo
err
"POST
${
url
}
"
echo
info
"POST
${
url
}
"
local
job_url
=
$(
curl
--silent
--show-error
--request
POST
--header
"PRIVATE-TOKEN:
${
API_TOKEN
}
"
"
${
url
}
"
| jq
".web_url"
)
echo
"Manual job '
${
job_name
}
' started at:
${
job_url
}
"
echo
info
"Manual job '
${
job_name
}
' started at:
${
job_url
}
"
}
function
wait_for_job_to_be_done
()
{
...
...
@@ -324,10 +325,10 @@ function wait_for_job_to_be_done() {
local
job_id
=
$(
get_job_id
"
${
job_name
}
"
"
${
query_string
}
"
)
;
if
[
-z
"
${
job_id
}
"
]
;
then return
;
fi
echo
err
"Waiting for the '
${
job_name
}
' job to finish..."
echo
info
"Waiting for the '
${
job_name
}
' job to finish..."
local
url
=
"https://gitlab.com/api/v4/projects/
${
CI_PROJECT_ID
}
/jobs/
${
job_id
}
"
echo
"GET
${
url
}
"
echo
info
"GET
${
url
}
"
# In case the job hasn't finished yet. Keep trying until the job times out.
local
interval
=
30
...
...
@@ -342,13 +343,13 @@ function wait_for_job_to_be_done() {
done
local
elapsed_minutes
=
$((
elapsed_seconds
/
60
))
echo
err
"Waited '
${
job_name
}
' for
${
elapsed_minutes
}
minutes."
echo
info
"Waited '
${
job_name
}
' for
${
elapsed_minutes
}
minutes."
if
[[
"
${
job_status
}
"
==
"failed"
]]
;
then
echo
"The '
${
job_name
}
' failed."
echo
err
"The '
${
job_name
}
' failed."
elif
[[
"
${
job_status
}
"
==
"manual"
]]
;
then
echo
"The '
${
job_name
}
' is manual."
echo
info
"The '
${
job_name
}
' is manual."
else
echo
"The '
${
job_name
}
' passed."
echo
info
"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