-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
114 lines (102 loc) · 2.69 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
pipeline {
agent any
tools {
gradle "Gradle 2.10"
}
environment {
VERSION = "${UUID.randomUUID().toString().replace('-','')[0..6]}"
}
stages {
stage('Build App') {
when {
expression {
env.BRANCH_NAME in ["master","stage","production"]
}
}
steps{
echo 'Building app'
sh 'gradle clean build -x test'
}
}
stage('Download Config'){
when {
expression {
env.BRANCH_NAME in ["master","stage","production"]
}
}
steps{
dir("configFiles"){
sh "git clone -b ${env.BRANCH_NAME} --single-branch [email protected]:techmindsmx/sepomex.git ."
}
}
}
stage('Preparing build Image Docker'){
when {
expression {
env.BRANCH_NAME in ["master","stage","production"]
}
}
steps{
sh 'cp configFiles/application-PRODUCTION.yml .'
dir("folderDocker"){
sh "git clone [email protected]:makingdevs/Tomcat-Docker.git ."
}
sh 'mv folderDocker/* .'
sh 'mv build/libs/sepomex-0.0.1-SNAPSHOT.war .'
sh 'mv sepomex-0.0.1-SNAPSHOT.war ROOT.war'
}
}
stage('Build image docker') {
when {
expression {
env.BRANCH_NAME in ["master","stage","production"]
}
}
steps{
script {
docker.withTool('Docker') {
docker.withRegistry('https://752822034914.dkr.ecr.us-east-1.amazonaws.com/sepomex', 'ecr:us-east-1:techminds-aws') {
def customImage = docker.build("sepomex:${env.VERSION}", '--build-arg URL_WAR=ROOT.war --build-arg FILE_NAME_CONFIGURATION=application-PRODUCTION.yml --build-arg PATH_NAME_CONFIGURATION=/root/.sepomex/ .')
customImage.push()
}
}
}
}
}
stage('Deploy Docker Machine development') {
when {
expression {
env.BRANCH_NAME == "master"
}
}
steps{
sh "ssh [email protected] sh /home/ec2-user/deployApps.sh ${env.VERSION} development sepomex 8084 8080"
}
}
stage('Deploy Docker Machine stage') {
when {
expression {
env.BRANCH_NAME == "stage"
}
}
steps{
sh "ssh [email protected] sh /home/ec2-user/deployApps.sh ${env.VERSION} stage sepomex 8085 8080"
}
}
stage('Deploy Docker Machine production') {
when {
expression {
env.BRANCH_NAME == "production"
}
}
steps{
sh "ssh [email protected] sh /home/ec2-user/deployApps.sh ${env.VERSION} production sepomex 8086 8080"
}
}
}
post {
always {
cleanWs()
}
}
}