Commit 04362cb9 authored by Bùi Bá Trường's avatar Bùi Bá Trường

truongbb - test ci

parent 815face4
Pipeline #370 failed with stages
in 1 minute and 9 seconds
...@@ -16,6 +16,7 @@ stages: ...@@ -16,6 +16,7 @@ stages:
- checkout - checkout
- compile - compile
- sonnar_scanner - sonnar_scanner
- check_quality_gate
- build_up # for merge request - build_up # for merge request
- send_email - send_email
...@@ -55,6 +56,17 @@ sonnar_scanner: ...@@ -55,6 +56,17 @@ sonnar_scanner:
- chmod +x ./build-test.sh - chmod +x ./build-test.sh
- ./build-test.sh sonar-scan - ./build-test.sh sonar-scan
check_quality_gate:
stage: check_quality_gate
only:
- master
# - merge_requests
script:
- cd /root/GitlabRunner/repo/spring-ci-advanced
- ls
- chmod +x ./build-test.sh
- ./build-test.sh quality-gate
build_up: build_up:
stage: build_up stage: build_up
only: only:
......
...@@ -11,6 +11,7 @@ sub_help(){ ...@@ -11,6 +11,7 @@ sub_help(){
echo " checkout Checkout code from git" echo " checkout Checkout code from git"
echo " compile Compile java code" echo " compile Compile java code"
echo " sonar-scan Run sonar scanner" echo " sonar-scan Run sonar scanner"
echo " quality-gate Check quality gate"
echo " send-email Send email after stage/pipeline" echo " send-email Send email after stage/pipeline"
echo "" echo ""
echo "For help with each sub-command run:" echo "For help with each sub-command run:"
...@@ -42,6 +43,10 @@ sub_sonar-scan(){ ...@@ -42,6 +43,10 @@ sub_sonar-scan(){
mvn clean --settings settings.xml package sonar:sonar \ mvn clean --settings settings.xml package sonar:sonar \
-Dsonar.projectName='SpringCIAdvanced' \ -Dsonar.projectName='SpringCIAdvanced' \
-Dsonar.projectKey='spring-ci-advanced' -Dsonar.projectKey='spring-ci-advanced'
}
sub_quality-gate(){
# curl -s -w "\n%{http_code}" 'http://192.168.1.210:9000/api/qualitygates/project_status?projectKey=spring-ci' | { # curl -s -w "\n%{http_code}" 'http://192.168.1.210:9000/api/qualitygates/project_status?projectKey=spring-ci' | {
# echo "1111111111111111111111" # echo "1111111111111111111111"
# read body # read body
...@@ -49,6 +54,7 @@ sub_sonar-scan(){ ...@@ -49,6 +54,7 @@ sub_sonar-scan(){
# echo ${code} # echo ${code}
# jq .name <<< "$body" # jq .name <<< "$body"
# } # }
# response=$(curl -s -w "\n%{http_code}" 'http://192.168.1.210:9000/api/qualitygates/project_status?projectKey=spring-ci') # response=$(curl -s -w "\n%{http_code}" 'http://192.168.1.210:9000/api/qualitygates/project_status?projectKey=spring-ci')
# response=(${response[@]}) # convert to array # response=(${response[@]}) # convert to array
# code=${response[-1]} # get last element (last line) # code=${response[-1]} # get last element (last line)
...@@ -56,10 +62,17 @@ sub_sonar-scan(){ ...@@ -56,10 +62,17 @@ sub_sonar-scan(){
# bodyRes=$(echo $body | jq '.bodyRes') # bodyRes=$(echo $body | jq '.bodyRes')
# echo $code # echo $code
# echo "body: "$bodyRes # echo "body: "$bodyRes
res=$( curl --request POST \
--url http://192.168.1.210:9000/api/qualitygates/project_status?projectKey=spring-ci \ # res=$( curl --request POST \
--header 'cache-control: no-cache' --header 'content-type: application/json' | jq '.res') # --url http://192.168.1.210:9000/api/qualitygates/project_status?projectKey=spring-ci \
echo "${res}" # --header 'cache-control: no-cache' --header 'content-type: application/json' | jq '.res')
# echo "${res}"
content=$(curl --request POST \
# --url http://192.168.1.210:9000/api/qualitygates/project_status?projectKey=spring-ci \
# --header 'cache-control: no-cache' --header 'content-type: application/json')
status=$( echo jq -r '.data.projectStatus.status' <<< "${content}" )
echo ${status}
} }
sub_send-email(){ sub_send-email(){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment