-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
62 lines (59 loc) · 1.5 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
pipeline {
agent any
stages {
stage('Instalamos dependencias') {
steps {
sh ''' echo "Instalamos dependencias"
pwd
cp /jenkinsCredentials/application.properties src/main/resources/application.properties
ls -la src/main/resources
'''
}
}
stage('Compilamos') {
steps {
sh '''
echo "Compilamos "
mvn package
'''
}
}
stage('Construimos la imagen docker') {
when{
branch 'Produccion'
}
steps {
sh '''
echo "Contruimos la imagen docker"
cp ./target/app.war ./app.war
docker build -t back-java .
'''
}
}
stage('Deploying image docker'){
when{
branch 'Produccion'
}
steps {
sh '''
echo "Desplegamos la imagen docker creada"
docker stop java
docker container rm java
docker run -d --name java --network host back-java
'''
}
}
stage('Deploying to docker hub'){
when{
branch 'Produccion'
}
steps {
sh '''
echo "subimos a docker hub"
docker tag back-java docker.tresee.app/back-java
docker push docker.tresee.app/back-java
'''
}
}
}
}