forked from brunoespinosadiaz/holamundo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.groovy
81 lines (75 loc) · 2.23 KB
/
deploy.groovy
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
pipeline{
agent {
label 'master'
}
/*
tools {
maven 'maven 3.6'
jdk 'java'
}
*/
environment {
// This can be nexus3 or nexus2
NEXUS_VERSION = "nexus3"
// This can be http or https
NEXUS_PROTOCOL = "http"
// Where your Nexus is running. 'nexus-3' is defined in the docker-compose file
NEXUS_URL = "192.168.42.129:8081"
// Repository where we will upload the artifact
NEXUS_REPOSITORY = "maven-releases"
// Jenkins credential id to authenticate to Nexus OSS
NEXUS_CREDENTIAL_ID = "nexus-credentials"
// Workfolder
//WORKFOLDER = "/usr/jenkins/node_agent/workspace"
}
stages{
stage('Checkout'){
steps{
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'github_jtassi', url: '[email protected]:calamza/holamundo.git']]])
}
}
stage('Download artifact from nexus'){
agent {
label 'master'
}
steps{
sh '''
pwd
curl -v -u admin:Hola1234 -o app.jar http://192.168.42.129:8081/repository/maven-public/org/springframework/jb-hello-world-maven/0.2.1/jb-hello-world-maven-0.2.1.jar
'''
}
}
stage('Build container'){
agent {
label 'dockers'
}
steps{
sh '''
docker build -t holamundo .
'''
}
} //fin stage build container
stage('Deploy container'){
agent {
label 'dockers'
}
steps{
sh '''
docker run -it --name holamundo -p 8080:80 holamundo
'''
}
} //fin stage build container
stage("Post") {
agent {
label 'dockerss'
}
steps {
sh '''
pwd
echo "Clean up workfolder"
rm -Rf *
'''
}
} //fin stage post
}
}