-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
129 lines (116 loc) · 2.96 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
pipeline {
agent any
tools {
gradle "Gradle 2.10"
}
environment {
VERSION = "${UUID.randomUUID().toString().replace('-','')[0..6]}"
}
stages {
stage('Update Assets') {
steps{
nodejs(nodeJSInstallationName: 'Node 10.1.0') {
echo 'Updating bower'
sh 'bower install'
sh 'coffee --compile src/main/resources/webroot/coffee'
}
}
}
stage('Test App') {
steps{
echo 'Testing app'
sh 'gradle clean test'
}
}
stage('Build App') {
when {
expression {
env.BRANCH_NAME in ["master","stage","production"]
}
}
steps{
echo 'Building app'
sh 'gradle clean shadowJar -x test'
}
}
stage('Download Config'){
when {
expression {
env.BRANCH_NAME in ["master","stage","production"]
}
}
steps{
dir("configFiles"){
sh "git clone -b ${env.BRANCH_NAME}-new --single-branch [email protected]:techmindsmx/config-emailer.git ."
}
}
}
stage('Preparing build Image Docker'){
when {
expression {
env.BRANCH_NAME in ["master","stage","production"]
}
}
steps{
sh 'cp configFiles/conf.json .'
dir("folderDocker"){
sh "git clone [email protected]:makingdevs/Java-Jar-Docker.git ."
}
sh 'mv folderDocker/* .'
sh 'mv build/libs/app.jar .'
}
}
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/emailer', 'ecr:us-east-1:techminds-aws') {
def customImage = docker.build("emailer:${env.VERSION}", '--build-arg URL_WAR=app.jar --build-arg FILE_NAME_CONFIGURATION=conf.json --build-arg PATH_NAME_CONFIGURATION=/root/emailer/ .')
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 emailer 8081 8000"
}
}
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 emailer 8082 8000"
}
}
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 emailer 8083 8000"
}
}
}
post {
always {
cleanWs()
}
}
}