-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
49 lines (49 loc) · 1.95 KB
/
Copy pathJenkinsfile
File metadata and controls
49 lines (49 loc) · 1.95 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
pipeline {
// Mandatory to use per-stage agents
agent none
stages {
//jvm tests a run during image creation, not nassesary to do it twise
stage('Staging image creation') {
agent any
steps {
// The Dockerfile.artifact copies the code into the image and run the jar generation.
echo 'Creating the image...'
// This will search for a Dockerfile.artifact in the working directory and build the image to the local repository
sh "docker build -t \"ditas/keycloak:staging\" -f Dockerfile ."
echo "Done"
echo 'Retrieving Docker Hub password from /opt/ditas-docker-hub.passwd...'
// Get the password from a file. This reads the file from the host, not the container. Slaves already have the password in there.
script {
password = readFile '/opt/ditas-docker-hub.passwd'
}
echo "Done"
echo 'Login to Docker Hub as ditasgeneric...'
sh "docker login -u ditasgeneric -p ${password}"
echo "Done"
echo "Pushing the image ditas/keycloak:staging"
sh "docker push ditas/keycloak:staging"
echo "Done "
}
}
stage('Deployment in Staging') {
agent any
steps {
sh './jenkins/deploy/deploy-staging.sh'
}
}
//API test ommited as this is a already tested system (keycloak)
stage('Production image creation') {
agent any
steps {
sh "docker tag ditas/keycloak:staging ditas/keycloak:production"
sh "docker push ditas/keycloak:production"
}
}
stage('Deployment in Production') {
agent any
steps {
sh './jenkins/deploy/deploy-production.sh'
}
}
}
}