-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile.groovy
94 lines (54 loc) · 2.64 KB
/
jenkinsfile.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
82
83
84
85
86
87
88
89
90
91
92
node {
stage('Descargar fuentes') {
git credentialsId: 'alt.carlos@gmail.com', url: 'https://github.com/ch4rl1/jbgroup-devops-facturacion.git'
}
stage('Compilar') {
bat 'mvn -f facturacion-web/pom.xml clean compile'
}
stage('Pruebas Unitarias') {
bat 'mvn -f facturacion-web/pom.xml test'
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/*.xml'])
}
stage('Pruebas de Integración') {
def SCRIPT_CREACION_BD = "${WORKSPACE}/facturacion-web/src/main/resources/db/create_database_integration_test_mysql.sql"
def SCRIPT_ELIMINACION_BD = "${WORKSPACE}/facturacion-web/src/main/resources/db/delete_database_integration_test_mysql.sql"
dir("c:\\xampp\\mysql\\bin"){
bat "mysql --user=test --password=test -e \"source ${SCRIPT_CREACION_BD}\""
bat "mvn -f \"${WORKSPACE}/facturacion-web/pom.xml\" verify -DskipUTs=true"
bat "mysql --user=test --password=test -e \"source ${SCRIPT_ELIMINACION_BD}\""
}
step([$class: 'JUnitResultArchiver', testResults: '**/target/failsafe-reports/*.xml'])
}
stage('Análisis Estático con Sonar') {
withSonarQubeEnv('MiSonarServer') {
bat 'mvn -f facturacion-web/pom.xml sonar:sonar'
/*def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "La aplicación no cumple con los estándares de calidad: ${qg.status}"
}*/
}
}
// No need to occupy a node
stage("Quality Gate"){
timeout(time: 5, unit: 'MINUTES') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "${qg.status}: La aplicación no cumple con los estándares de calidad: ${qg.status}"
}
}
}
stage('Empaquetar y Versionar') {
bat 'mvn -f facturacion-web/pom.xml package -DskipTests=true'
def server = Artifactory.server 'MiArtifactory'
def uploadSpec = """{
"files": [
{
"pattern": "facturacion-web/target/*.jar",
"target": "aplicaciones-java/FacturacionWeb/${BUILD_NUMBER}/",
"props": "pruebas-unitarias=si;pruebas-integracion=si"
}
]
}"""
server.upload(uploadSpec)
}
}