Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Akamu
Game Client iOS
Commits
3c0d6521
Commit
3c0d6521
authored
Jul 26, 2020
by
Maurice Kraus
Browse files
build: this refactors the script
parent
5d218f30
Pipeline
#1912
waiting for manual action with stages
in 26 minutes and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gitrise.sh
View file @
3c0d6521
...
...
@@ -14,7 +14,7 @@ previous_build_status_text=""
exit_code
=
""
log_url
=
""
usage
()
{
usage
()
{
echo
""
echo
"Usage: gitrise [options]"
echo
...
...
@@ -176,7 +176,7 @@ get_build_status () {
}
get_follow_log
()
{
local
test_call_counter
=
-1
local
test_call_counter
=
0
local
response
=
""
local
counter
=
0
local
retry
=
3
...
...
@@ -184,14 +184,17 @@ get_follow_log () {
local
log_is_archived
=
"false"
local
current_position
=
0
local
current_timestamp_query
=
""
local command
=
""
while
[
"
${
log_is_archived
}
"
=
"false"
]
;
do
if
[
-z
"
${
TESTING_ENABLED
}
"
]
;
then
sleep
"
$polling_interval
"
local
command
=
"curl --silent -X GET -w
\"\n
%{http_code}
\n\"
'https://app.bitrise.io/api/build/
$build_slug
/logs.json?is_include_log_chunks=true
$current_timestamp_query
' --header 'Accept: application/json' --header 'Authorization:
$ACCESS_TOKEN
'"
command
=
"curl --silent -X GET -w
\"\n
%{http_code}
\n\"
'https://app.bitrise.io/api/build/
$build_slug
/logs.json?is_include_log_chunks=true
$current_timestamp_query
' --header 'Accept: application/json' --header 'Authorization:
$ACCESS_TOKEN
'"
response
=
$(
eval
"
${
command
}
"
)
else
command
=
"https://app.bitrise.io/api/build/[REDACTED]/logs.json?is_include_log_chunks=true
$current_timestamp_query
"
((
test_call_counter++
))
response
=
$(
< ./testdata/
"
$1
"
)
response
=
$(
< ./testdata/
"
$1
_$test_call_counter
"
.json
)
fi
if
[[
"
$response
"
!=
*
"<!DOCTYPE html>"
*
]]
;
then
...
...
@@ -207,8 +210,8 @@ get_follow_log () {
current_position
=
$(
echo
"
${
positions
[
${#
positions
[@]
}
-1]
}
"
)
for
i
in
"
${
chunks
[@]
}
"
;
do
echo
-e
"
$i
"
[
"
$DEBUG
"
==
"true"
]
&&
log
"
${
command
%%
'--header'
*
}
"
"
$i
"
"get_follow
_status
.log"
echo
-e
$i
[
"
$DEBUG
"
==
"true"
]
&&
log
"
${
command
%%
'--header'
*
}
"
"
$i
"
"get_follow.log"
done
else
if
[[
$counter
-lt
$retry
]]
;
then
...
...
@@ -222,7 +225,7 @@ get_follow_log () {
done
}
process
(){
process
()
{
local
response
=
"
$1
"
local
current_build_status_text
=
$(
echo
"
$response
"
| jq
".data .status_text"
|
sed
's/"//g'
)
if
[
"
$previous_build_status_text
"
!=
"
$current_build_status_text
"
]
;
then
...
...
@@ -254,7 +257,7 @@ build_status_message () {
esac
}
get_log_info
(){
get_log_info
()
{
local
log_is_archived
=
false
local
counter
=
0
local
retry
=
4
...
...
@@ -281,19 +284,21 @@ get_log_info(){
fi
}
get_logs
(){
local
url
=
"
$1
"
local
logs
=
$(
curl
--silent
-X
GET
"
$url
"
)
render_logs
()
{
echo
"================================================================================"
echo
"============================== Bitrise Logs Start =============================="
echo
"
$logs
"
"
$1
"
echo
"================================================================================"
echo
"============================== Bitrise Logs End =============================="
}
get_logs
()
{
local
url
=
"
$1
"
local
logs
=
$(
curl
--silent
-X
GET
"
$url
"
)
echo
"
$logs
"
}
log
(){
log
()
{
local
request
=
"
$1
"
local
response
=
"
$2
"
local
log_file
=
"
$3
"
...
...
@@ -308,14 +313,14 @@ log(){
if
[
"
$0
"
=
"
${
BASH_SOURCE
[0]
}
"
]
&&
[
-z
"
${
TESTING_ENABLED
}
"
]
;
then
trigger_build
if
[
"
$FOLLOW
"
==
"true"
]
;
then
get_follow_log
get_log_info
get_logs
"
$log_url
"
render_logs get_follow_log
get_build_status
build_status_message
"
$build_status
"
else
get_build_status
get_log_info
get_logs
"
$log_url
"
logs
=
`
get_logs
"
$log_url
"
`
render_logs
"
$logs
"
build_status_message
"
$build_status
"
fi
exit
${
exit_code
}
...
...
Write
Preview
Supports
Markdown
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