Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
a1849ef0
Commit
a1849ef0
authored
4 years ago
by
hahn
Browse files
Options
Downloads
Patches
Plain Diff
task 3975 - update api shell script
parent
3098afcb
No related branches found
No related tags found
1 merge request
!1
Task 3975 add gitlab ci yaml
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shellscripts/api-imlciserver.sh
+22
-6
22 additions, 6 deletions
shellscripts/api-imlciserver.sh
with
22 additions
and
6 deletions
shellscripts/api-imlciserver.sh
+
22
−
6
View file @
a1849ef0
...
...
@@ -4,7 +4,8 @@
# API CLIENT :: API REQUEST TO IML CI SERVER
#
# ----------------------------------------------------------------------
# 2020-07-23 first lines <axel.hahn@iml.unibe.ch>
# 2020-07-23 v1.0 <axel.hahn@iml.unibe.ch> first lines
# 2020-07-29 v1.1 <axel.hahn@iml.unibe.ch> check "/" in branch; check http status 200
# ======================================================================
# ----------------------------------------------------------------------
...
...
@@ -54,6 +55,8 @@ function makeRequest(){
local
apiRequest
=
$2
local
secret
=
$3
local
outfile
=
$(
mktemp
)
echo
$line
echo
$apiMethod
${
apiHost
}${
apiRequest
}
echo
$line
...
...
@@ -81,12 +84,22 @@ ${apiTS}
-H
"Date:
${
apiTS
}
"
\
-H
"Authorization: demo-bash-client:
${
myHash
}
"
\
-X
$apiMethod
\
${
IMLCI_URL
}${
apiRequest
}
${
IMLCI_URL
}${
apiRequest
}
|
tee
-a
$outfile
else
curl
-i
\
-H
"Accept: application/json"
-H
"Content-Type: application/json"
\
-X
$apiMethod
\
${
IMLCI_URL
}${
apiRequest
}
${
IMLCI_URL
}${
apiRequest
}
|
tee
-a
$outfile
fi
grep
"^HTTP
\/
"
$outfile
|
head
-1
|
grep
" 200 "
>
/dev/null
local
rccurl
=
$?
rm
-f
$outfile
if
[
$rccurl
-ne
0
]
;
then
echo
echo
"ERROR: API request failed. CURL request did not get respond status code 200."
exit
4
fi
}
...
...
@@ -123,7 +136,7 @@ case ${option} in
;;
*
)
echo
ERROR: invalid option
[
${
option
}
]
exit
1
exit
2
esac
done
...
...
@@ -133,6 +146,9 @@ echo "IMLCI_PROJECT = $IMLCI_PROJECT"
echo
"IMLCI_API_SECRET =
$IMLCI_API_SECRET
"
echo
echo
$branch
|
grep
'/.*/.*'
>
/dev/null
&&
(
echo
"WARNING: Do NOT use a branch containing a slash [/] in the name"
;
echo
)
echo
ACTION:
$apiAction
case
$apiAction
in
...
...
@@ -153,7 +169,7 @@ case $apiAction in
;;
*
)
echo
"ERROR: unknown action [
$apiAction
]"
exit
2
exit
3
esac
rc
=
$?
...
...
@@ -162,4 +178,4 @@ echo $line
date
echo
rc
=
$rc
exit
$rc
\ No newline at end of file
exit
$rc
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment