File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ pipeline {
2
+ agent any
3
+
4
+ environment {
5
+ DOCKER_HUB_REPO = " shivammitra/flask-hello-world"
6
+ CONTAINER_NAME = " flask-hello-world"
7
+
8
+ }
9
+
10
+ stages {
11
+ /* We do not need a stage for checkout here since it is done by default when using "Pipeline script from SCM" option. */
12
+
13
+ stage(' Build' ) {
14
+ steps {
15
+ echo ' Building..'
16
+ sh ' docker image build -t $DOCKER_HUB_REPO:latest .'
17
+ }
18
+ }
19
+ stage(' Test' ) {
20
+ steps {
21
+ echo ' Testing..'
22
+ sh ' docker stop $CONTAINER_NAME || true'
23
+ sh ' docker rm $CONTAINER_NAME || true'
24
+ sh ' docker run --name $CONTAINER_NAME $DOCKER_HUB_REPO /bin/bash -c "pytest test.py && flake8"'
25
+ }
26
+ }
27
+ stage(' Deploy' ) {
28
+ steps {
29
+ echo ' Deploying....'
30
+ sh ' docker stop $CONTAINER_NAME || true'
31
+ sh ' docker rm $CONTAINER_NAME || true'
32
+ sh ' docker run -d -p 5000:5000 --name $CONTAINER_NAME $DOCKER_HUB_REPO'
33
+ }
34
+ }
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments