-
Notifications
You must be signed in to change notification settings - Fork 99
/
Jenkinsfile
63 lines (58 loc) · 1.71 KB
/
Jenkinsfile
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
63
pipeline {
agent any
environment {
ENV_TYPE = "dev"
APP_NAME = "bottlecrm-app"
DOCKERHUB = credentials("dockerhub")
DOCKER_IMAGE_TAG = "build-${env.BUILD_NUMBER}-${env.GIT_COMMIT[0..7]}"
DOCKER_IMAGE = "ashwin31/bottlecrm_uix:${env.DOCKER_IMAGE_TAG}"
DOCKER_CONFIG = "config.json"
}
stages {
stage("build") {
steps {
sh "pwd; whoami; ls -al;"
sh "docker build --build-arg APP_NAME=$APP_NAME -t ${env.DOCKER_IMAGE} ."
}
}
stage("push") {
steps {
sh "echo '$DOCKERHUB_PSW' | docker login -u $DOCKERHUB_USR --password-stdin"
sh "docker push ${env.DOCKER_IMAGE}"
}
}
stage('trigger deploy') {
steps {
build job: 'deploy', parameters: [
string(
name: 'ENV_TYPE',
value: "${env.ENV_TYPE}"
),
string(
name: 'APP_NAME',
value: "${env.APP_NAME}"
),
string(
name: 'DOCKER_IMAGE',
value: "${env.DOCKER_IMAGE}"
)
]
}
}
}
post {
always {
cleanWs()
dir("${env.WORKSPACE}@tmp") {
deleteDir()
}
dir("${env.WORKSPACE}@script") {
deleteDir()
}
dir("${env.WORKSPACE}@script@tmp") {
deleteDir()
}
sh 'docker rmi $(docker images -aq) || true'
}
}
}