-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
59 lines (55 loc) · 2.09 KB
/
Jenkinsfile
File metadata and controls
59 lines (55 loc) · 2.09 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
pipeline {
agent none
stages {
stage('Build and test') {
agent {
dockerfile {
filename 'Dockerfile.build'
}
}
steps {
// Build
sh "echo skipping"
//sh "jenkins/build.sh ${WORKSPACE}"
}
}
stage('Image creation') {
agent any
options {
skipDefaultCheckout true
}
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/slalite:staging\" -f Dockerfile ."
echo "Done"
// Get the password from a file. This reads the file from the host, not the container. Slaves already have the password in there.
echo 'Retrieving Docker Hub password from /opt/ditas-docker-hub.passwd...'
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/slalite:staging..."
sh "docker push ditas/slalite:staging"
echo "Done "
}
}
stage('Image deploy') {
agent any
options {
// Don't need to checkout Git again
skipDefaultCheckout true
}
steps {
// TODO: Uncomment this when the previous stages run correctly
// TODO: Remember to edit 'deploy-staging.sh' and configure the ports
// Deploy to Staging environment calling the deployment script
sh './jenkins/deploy/deploy-staging.sh'
}
}
}
}