-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile
53 lines (51 loc) · 1.53 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
pipeline {
agent none
stages {
stage('Build - test') {
agent {
docker {
image 'maven:latest'
// TODO some cache to avoid npm sintall on every execution?
}
}
steps {
sh 'echo "Building! new"'
//sh 'npm install --prefix src'
sh 'mvn test'
}
}
stage('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/SecureService\" -f Dockerfile.artifact ."
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/data-utility-resolution-engine:latest..."
sh "docker push ditas/data-utility-resolution-engine:latest"
echo "Done "
}
}
stage('Image deploy') {
agent any
options {
// Don't need to checkout Git again
skipDefaultCheckout true
}
steps {
// Deploy to Staging environment calling the deployment script
sh './jenkins/deploy-staging.sh'
}
}
}
}