-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
68 lines (61 loc) · 1.34 KB
/
Jenkinsfile
File metadata and controls
68 lines (61 loc) · 1.34 KB
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
pipeline {
agent any
options {
skipDefaultCheckout()
}
tools {
nodejs "node"
}
environment {
registry = "joseantoniotortosa/devhub"
registryCredential = 'id'
dockerImage = ''
}
stages {
stage('Install') {
steps {
git branch: 'main', url: 'https://github.com/Atechnea/DevHub.git'
dir('Test') {
echo 'Descargando la última versión...'
sh 'npm install'
}
}
}
stage('Testing') {
steps {
dir('Test') {
echo 'Ejecutando los tests...'
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh 'npx jest Test'
}
}
script {
if (currentBuild.result == 'FAILURE') {
echo 'Los tests han fallado. Realizando acción específica...'
error 'Los tests han fallado.' //Si los test no funcionan, marcamos la etapa como fallida
} else {
echo 'Los tests han pasado satisfactoriamente.'
}
}
}
}
stage('Build') {
steps {
script {
echo 'Creando versión actual...'
dockerImage = docker.build(registry)
}
}
}
stage('Deploy') {
steps {
script {
echo 'Generando nueva versión...'
docker.withRegistry('', registryCredential) {
dockerImage.push()
}
}
}
}
}
}