forked from PS1115-Skala/backend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
66 lines (64 loc) · 2.18 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
pipeline {
agent any
environment {
// user= en credenciales de jenkins
// password = en credenciales de jenkins
host='localhost'
database = 'reserva'
port = 5432
registry = 'backend_cont_test'
}
stages {
stage('Clone repo') {
steps {
git 'https://github.com/jkauze/backend'
}
}
stage('Building') {
steps {
sh 'echo Backend no amerita compilacion' //Este paso no es necesario para el backend
}
}
stage('Tests Result') {
steps {
script {
def dockerfile = './Dockerfile'
def dockerImage = docker.build("${registry}:${env.BUILD_ID}", "-f ${dockerfile} .")
// Connect to docker cont and run tests
try {
withCredentials([usernamePassword(credentialsId: 'user_pass_postgres', passwordVariable: 'password', usernameVariable: 'user')]) {
dockerImage.inside("--network host") {
sh 'npm run test'
}
}
} finally {
// Removing the docker image
sh "docker rmi $registry:$BUILD_NUMBER"
}
}
}
}
stage('deploy') {
steps {
sh 'echo ChangeServer'
}
}
}
post {
always {
script {
if (currentBuild.currentResult == 'FAILURE') {
// Send an email only if the build status has changed from green/unstable to red
emailext subject: ' $DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
recipientProviders: [
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
replyTo: '$DEFAULT_REPLYTO',
to: '$DEFAULT_RECIPIENTS'
}
}
}
}
}