Skip to content
Snippets Groups Projects
Commit dbbcb1ee authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'task-3975-add-gitlab-ci-yaml' into 'master'

Task 3975 add gitlab ci yaml

See merge request !1
parents 7eb396bf a1849ef0
No related branches found
No related tags found
1 merge request!1Task 3975 add gitlab ci yaml
Pipeline #29 passed
deploy_prod:
stage: deploy
script:
- export IMLCI_URL=$IMLCI_URL
- export IMLCI_PROJECT=$IMLCI_PROJECT
- export IMLCI_API_SECRET=$IMLCI_API_SECRET
- /usr/local/bin/api-imlciserver.sh -a build -b origin/$CI_COMMIT_BRANCH
only:
- master
\ No newline at end of file
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
# API CLIENT :: API REQUEST TO IML CI SERVER # 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(){ ...@@ -54,6 +55,8 @@ function makeRequest(){
local apiRequest=$2 local apiRequest=$2
local secret=$3 local secret=$3
local outfile=$( mktemp )
echo $line echo $line
echo $apiMethod ${apiHost}${apiRequest} echo $apiMethod ${apiHost}${apiRequest}
echo $line echo $line
...@@ -81,12 +84,22 @@ ${apiTS} ...@@ -81,12 +84,22 @@ ${apiTS}
-H "Date: ${apiTS}" \ -H "Date: ${apiTS}" \
-H "Authorization: demo-bash-client:${myHash}" \ -H "Authorization: demo-bash-client:${myHash}" \
-X $apiMethod \ -X $apiMethod \
${IMLCI_URL}${apiRequest} ${IMLCI_URL}${apiRequest} | tee -a $outfile
else else
curl -i \ curl -i \
-H "Accept: application/json" -H "Content-Type: application/json" \ -H "Accept: application/json" -H "Content-Type: application/json" \
-X $apiMethod \ -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 fi
} }
...@@ -123,7 +136,7 @@ case ${option} in ...@@ -123,7 +136,7 @@ case ${option} in
;; ;;
*) *)
echo ERROR: invalid option [${option}] echo ERROR: invalid option [${option}]
exit 1 exit 2
esac esac
done done
...@@ -133,6 +146,9 @@ echo "IMLCI_PROJECT = $IMLCI_PROJECT" ...@@ -133,6 +146,9 @@ echo "IMLCI_PROJECT = $IMLCI_PROJECT"
echo "IMLCI_API_SECRET = $IMLCI_API_SECRET" echo "IMLCI_API_SECRET = $IMLCI_API_SECRET"
echo echo
echo $branch | grep '/.*/.*' >/dev/null && ( echo "WARNING: Do NOT use a branch containing a slash [/] in the name"; echo )
echo ACTION: $apiAction echo ACTION: $apiAction
case $apiAction in case $apiAction in
...@@ -153,7 +169,7 @@ case $apiAction in ...@@ -153,7 +169,7 @@ case $apiAction in
;; ;;
*) *)
echo "ERROR: unknown action [$apiAction]" echo "ERROR: unknown action [$apiAction]"
exit 2 exit 3
esac esac
rc=$? rc=$?
...@@ -162,4 +178,4 @@ echo $line ...@@ -162,4 +178,4 @@ echo $line
date date
echo rc=$rc echo rc=$rc
exit $rc exit $rc
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment