Commit 5b4d3e7a authored by Bùi Bá Trường's avatar Bùi Bá Trường

test

parent a7e09490
Pipeline #469 failed
...@@ -13,26 +13,21 @@ variables: ...@@ -13,26 +13,21 @@ variables:
QUALITY_GATE: "OK" QUALITY_GATE: "OK"
stages: stages:
- checkout - checkout_code
- compile - compile
- sonnar_scanner - sonnar_scanner
- check_quality_gate - check_quality_gate
- dokcer_build - docker_build
- docker_up
- docker_push
- send_email - send_email
checkout: checkout_code:
stage: checkout stage: checkout_code
only: only:
- master - master
- merge_request - merge_request
script: script:
# - cd /root/GitlabRunner/repo/
# - ls
# - rm -rf ./spring-ci-advanced
# - git config --global user.name 'truongbb96'
# - git config --global user.email 'truongbb@itsol.vn'
# - git clone https://truongbb96:hoanghuynh0801@git.myitsol.com/truongbb96/spring-ci-advanced.git
# - cd ./spring-ci-advanced
- cd /root/GitlabRunner/repo/spring-ci-advanced - cd /root/GitlabRunner/repo/spring-ci-advanced
- git checkout - git checkout
- git pull - git pull
...@@ -71,14 +66,13 @@ check_quality_gate: ...@@ -71,14 +66,13 @@ check_quality_gate:
- export QUALITY_GATE=$(./build-test.sh quality-gate) - export QUALITY_GATE=$(./build-test.sh quality-gate)
- echo $QUALITY_GATE - echo $QUALITY_GATE
- echo "Sonar statistic result at --> http://192.168.1.210:9000/dashboard?id=spring-ci-advanced" - echo "Sonar statistic result at --> http://192.168.1.210:9000/dashboard?id=spring-ci-advanced"
# force pipeline exit and fail job if QUALITY GATE is FAIL - sh ./stop_job.sh # force pipeline exit and fail job if QUALITY GATE is FAIL
- sh ./stop_job.sh
dokcer_build: dokcer_build:
stage: dokcer_build stage: dokcer_build
only: only:
- master - master
# - merge_requestsss # - merge_request
script: script:
- cd /root/GitlabRunner/repo/spring-ci-advanced - cd /root/GitlabRunner/repo/spring-ci-advanced
- ls - ls
...@@ -87,14 +81,36 @@ dokcer_build: ...@@ -87,14 +81,36 @@ dokcer_build:
- ./build-test.sh docker-up - ./build-test.sh docker-up
- ./build-test.sh docker-push - ./build-test.sh docker-push
dokcer_up:
stage: dokcer_up
only:
- master
# - merge_request
script:
- cd /root/GitlabRunner/repo/spring-ci-advanced
- ls
- chmod +x ./build-test.sh
- ./build-test.sh docker-up
- ./build-test.sh docker-push
dokcer_push:
stage: dokcer_push
only:
- master
# - merge_request
script:
- cd /root/GitlabRunner/repo/spring-ci-advanced
- ls
- chmod +x ./build-test.sh
- ./build-test.sh docker-push
send_email: send_email:
stage: send_email stage: send_email
only: only:
- master - master
- merge_requests - merge_requests
script: script:
- curl --request POST - cd /root/GitlabRunner/repo/spring-ci-advanced
--url https://api.sendgrid.com/v3/mail/send - ls
--header 'Authorization:Bearer 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' - chmod +x ./build-test.sh
--header 'Content-Type:application/json' - ./build-test.sh send-email
--data '{"personalizations":[{"to":[{"email":"truongbb96@gmail.com"}]}],"from":{"email":"truongbb@itsol.vn"},"subject":"CI pipeline result","content":[{"type":"text/plain","value":"CI pipeline done!"}]}' \ No newline at end of file
\ No newline at end of file
...@@ -14,6 +14,7 @@ sub_help(){ ...@@ -14,6 +14,7 @@ sub_help(){
echo " quality-gate Check quality gate" echo " quality-gate Check quality gate"
echo " docker-build Build project with docker" echo " docker-build Build project with docker"
echo " docker-up Start services via docker" echo " docker-up Start services via docker"
echo " docker-push Push image to Nexus repository via docker"
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:"
...@@ -22,13 +23,14 @@ sub_help(){ ...@@ -22,13 +23,14 @@ sub_help(){
} }
sub_checkout(){ sub_checkout(){
# cd /root/GitlabRunner/repo/ # -------------CLONE-----------------
# ls # cd /root/GitlabRunner/repo/
# rm -rf ./spring-ci-advanced # rm -rf ./spring-ci-advanced
# git config --global user.name 'truongbb96' # git config --global user.name 'truongbb96'
# git config --global user.email 'truongbb@itsol.vn' # git config --global user.email 'truongbb@itsol.vn'
# git clone https://truongbb96:hoanghuynh0801@git.myitsol.com/truongbb96/spring-ci-advanced.git # git clone https://truongbb96:hoanghuynh0801@git.myitsol.com/truongbb96/spring-ci-advanced.git
# cd ./spring-ci-advanced # cd ./spring-ci-advanced
# ------------PULL----------------
cd /root/GitlabRunner/repo/spring-ci-advanced cd /root/GitlabRunner/repo/spring-ci-advanced
git checkout git checkout
git pull git pull
...@@ -54,10 +56,10 @@ sub_quality-gate(){ ...@@ -54,10 +56,10 @@ sub_quality-gate(){
if [[ ${qualityGateStatus} != "OK" ]] if [[ ${qualityGateStatus} != "OK" ]]
then then
# echo "*******QUALITY GATE FAILED!**********" # echo "*******QUALITY GATE FAILED!**********"
echo 0 echo "NOK"
else else
# echo "*******QUALITY GATE PASSED!**********" # echo "*******QUALITY GATE PASSED!**********"
echo 1 echo "OK"
fi fi
} }
...@@ -85,12 +87,23 @@ sub_docker-up(){ ...@@ -85,12 +87,23 @@ sub_docker-up(){
} }
sub_docker-push(){ sub_docker-push(){
if [[ -d 'commons/target' ]]
then
echo "Already packaged!"
else
echo "Need to package before building with docker-compose.."
sub_package
fi
#docker push 192.168.1.204:8082/spring-ci-advanced/dev/spring-ci-advanced:latest #docker push 192.168.1.204:8082/spring-ci-advanced/dev/spring-ci-advanced:latest
docker-compose -f deploy/docker-compose.yml push docker-compose -f deploy/docker-compose.yml push
} }
sub_send-email(){ sub_send-email(){
echo "TODO - send email" curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header 'Authorization:Bearer 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' \
--header 'Content-Type:application/json' \
--data '{"personalizations":[{"to":[{"email":"truongbb96@gmail.com"}]}],"from":{"email":"truongbb@itsol.vn"},"subject":"CI pipeline result","content":[{"type":"text/plain","value":"CI pipeline done!"}]}'
} }
_docker_mvn() { _docker_mvn() {
...@@ -99,7 +112,7 @@ _docker_mvn() { ...@@ -99,7 +112,7 @@ _docker_mvn() {
-v "$HOME/.m2:/root/.m2" \ -v "$HOME/.m2:/root/.m2" \
-w /usr/src/ \ -w /usr/src/ \
maven:3.6.1-jdk-11 \ maven:3.6.1-jdk-11 \
mvn -U clean $@ mvn --settings settings.xml -U clean $@
} }
sub_package() { sub_package() {
......
...@@ -16,4 +16,12 @@ ...@@ -16,4 +16,12 @@
</properties> </properties>
</profile> </profile>
</profiles> </profiles>
<mirrors>
<mirror>
<id>ITSOL</id>
<name>ITSOL JSC</name>
<url>http://http://192.168.1.204:8081/maven</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings> </settings>
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
if [[ $QUALITY_GATE = 0 ]] if [[ $QUALITY_GATE = 0 ]]
then then
echo "QUALITY GATE FAILED. CHECK SONAR SCANNER RESULT!" echo "QUALITY GATE FAILED. CHECK SONAR SCANNER RESULT!"
export QUALITY_GATE="OK"
exit -1 exit -1
else else
echo "QUALITY GATE PASSED. SONAR SCANNER'S SUCCESSFUL!" echo "QUALITY GATE PASSED. SONAR SCANNER'S SUCCESSFUL!"
......
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