Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spring-ci-advanced
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bùi Bá Trường
spring-ci-advanced
Commits
5b4d3e7a
Commit
5b4d3e7a
authored
Aug 01, 2019
by
Bùi Bá Trường
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
a7e09490
Pipeline
#469
failed
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
30 deletions
+68
-30
.gitlab-ci.yml
.gitlab-ci.yml
+35
-19
build-test.sh
build-test.sh
+24
-11
settings.xml
settings.xml
+8
-0
stop_job.sh
stop_job.sh
+1
-0
No files found.
.gitlab-ci.yml
View file @
5b4d3e7a
...
...
@@ -13,26 +13,21 @@ variables:
QUALITY_GATE
:
"
OK"
stages
:
-
checkout
-
checkout
_code
-
compile
-
sonnar_scanner
-
check_quality_gate
-
dokcer_build
-
docker_build
-
docker_up
-
docker_push
-
send_email
checkout
:
stage
:
checkout
checkout
_code
:
stage
:
checkout
_code
only
:
-
master
-
merge_request
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
-
git checkout
-
git pull
...
...
@@ -71,14 +66,13 @@ check_quality_gate:
-
export QUALITY_GATE=$(./build-test.sh quality-gate)
-
echo $QUALITY_GATE
-
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
-
sh ./stop_job.sh
# force pipeline exit and fail job if QUALITY GATE is FAIL
dokcer_build
:
stage
:
dokcer_build
only
:
-
master
# - merge_request
sss
# - merge_request
script
:
-
cd /root/GitlabRunner/repo/spring-ci-advanced
-
ls
...
...
@@ -87,14 +81,36 @@ dokcer_build:
-
./build-test.sh docker-up
-
./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
:
stage
:
send_email
only
:
-
master
-
merge_requests
script
:
-
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!"}]}'
\ No newline at end of file
-
cd /root/GitlabRunner/repo/spring-ci-advanced
-
ls
-
chmod +x ./build-test.sh
-
./build-test.sh send-email
\ No newline at end of file
build-test.sh
View file @
5b4d3e7a
...
...
@@ -14,6 +14,7 @@ sub_help(){
echo
" quality-gate Check quality gate"
echo
" docker-build Build project with 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
""
echo
"For help with each sub-command run:"
...
...
@@ -22,13 +23,14 @@ sub_help(){
}
sub_checkout
(){
# 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
# -------------CLONE-----------------
# cd /root/GitlabRunner/repo/
# 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
# ------------PULL----------------
cd
/root/GitlabRunner/repo/spring-ci-advanced
git checkout
git pull
...
...
@@ -54,10 +56,10 @@ sub_quality-gate(){
if
[[
${
qualityGateStatus
}
!=
"OK"
]]
then
# echo "*******QUALITY GATE FAILED!**********"
echo
0
echo
"NOK"
else
# echo "*******QUALITY GATE PASSED!**********"
echo
1
echo
"OK"
fi
}
...
...
@@ -85,12 +87,23 @@ sub_docker-up(){
}
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-compose
-f
deploy/docker-compose.yml push
}
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
()
{
...
...
@@ -99,7 +112,7 @@ _docker_mvn() {
-v
"
$HOME
/.m2:/root/.m2"
\
-w
/usr/src/
\
maven:3.6.1-jdk-11
\
mvn
-U
clean
$@
mvn
-
-settings
settings.xml
-
U
clean
$@
}
sub_package
()
{
...
...
settings.xml
View file @
5b4d3e7a
...
...
@@ -16,4 +16,12 @@
</properties>
</profile>
</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>
\ No newline at end of file
stop_job.sh
View file @
5b4d3e7a
...
...
@@ -5,6 +5,7 @@
if
[[
$QUALITY_GATE
=
0
]]
then
echo
"QUALITY GATE FAILED. CHECK SONAR SCANNER RESULT!"
export
QUALITY_GATE
=
"OK"
exit
-1
else
echo
"QUALITY GATE PASSED. SONAR SCANNER'S SUCCESSFUL!"
...
...
Write
Preview
Markdown
is supported
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