-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjenkins-cicd.sh
62 lines (49 loc) · 1.75 KB
/
jenkins-cicd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Script meant to be invoked via Jenkins to Demonstrate end-to-end CI/CD
# Author: Prasanjit Singh //www.binpipe.org//nixgurus@gmail.com
#------------------------------------------------------------------#
echo "*******-Starting CI CD Pipeline Tasks-*******"
#-BUILD
echo ""
echo "..... Build Phase Started :: Compiling Source Code :: ......"
#compilation not needed here as code is html
#workdir=${PWD##*/}
#
#if [ "$workdir" == "foldername" ]; then
# echo "correct folder"
#else
# echo "incorrect folder"
#fi
#cd $workdir
#-BUILD (TEST)
echo ""
echo "..... Test Phase Started :: Testing via Automated Scripts :: ......"
echo
#You can add your real test cases/scripts here!
echo "Dummy test cases running !! ..." ; sleep 10;
echo "Completed!"
#----------------------------------------#
echo ""
echo "..... Integration Phase Started :: Copying Artifacts :: ......"
chmod +x wrapper.sh
echo ""
echo "..... Provisioning Phase Started :: Building Docker Container :: ......"
docker build --tag parametrized-job-demo .
#if there is a public docker repository push it to public repo here-
#sudo docker push binpipe/parametrized-job-demo
#-POSTBUILD (PROVISIONING DEPLOYMENT)
CONTAINER=parametrized-job-demo
RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null)
if [ $? -eq 1 ]; then
echo "'$CONTAINER' does not exist."
else
docker rm -f $CONTAINER
fi
# run your container
echo ""
echo "..... Deployment Phase Started :: Building Docker Container :: ......"
docker run -d -p 8888:80 --name parametrized-job-demo parametrized-job-demo
#-Completion
echo "--------------------------------------------------------"
echo "View App deployed here: http://server-ip:8888"
echo "--------------------------------------------------------"