This repository has been archived by the owner on Aug 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
160 lines (151 loc) · 6.79 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
pipeline {
agent any
stages {
stage ('Checkout') {
options {
// Don't checkout the repo where it is this Jenkinsfles, just the target repos of this pipeline. Must be set at every stage.
skipDefaultCheckout true
}
parallel {
stage('Checkout vdc-logging') {
options { skipDefaultCheckout true }
steps {
dir('vdc-logging') {
git changelog: false, credentialsId: 'Aitor-IDEKO-GitHub', poll: false, url: 'https://github.com/DITAS-Project/VDC-Logging-Agent.git'
}
}
}
stage('Checkout vdc-request') {
options { skipDefaultCheckout true }
steps {
dir('vdc-request') {
git changelog: false, credentialsId: 'Aitor-IDEKO-GitHub', poll: false, url: 'https://github.com/DITAS-Project/VDC-Request-Monitor.git'
}
}
}
stage('Checkout vdc-throughput') {
options { skipDefaultCheckout true }
steps {
dir('vdc-throughput') {
git changelog: false, credentialsId: 'Aitor-IDEKO-GitHub', poll: false, url: 'https://github.com/DITAS-Project/VDC-Throughput-Agent.git'
}
}
}
}
}
stage ('Build - Test') {
options {
skipDefaultCheckout true
}
parallel {
stage('Build - test vdc-logging') {
agent {
dockerfile {
dir 'vdc-logging'
filename 'Dockerfile.testing' // Dockerfile only at this moment but should be Dockerfile.build
reuseNode true
}
}
steps {
sh "cd /go/src/github.com/DITAS-Project/VDC-Logging-Agent && go test ./..."
}
}
stage('Build vdc-throughput') {
agent {
dockerfile{
dir 'vdc-throughput'
filename 'Dockerfile.testing'
reuseNode true
}
}
steps {
sh "cd ./vdc-throughput/ && mvn test"
}
}
// we should test this but jenkins dosen´t let me so ... no testing it is!
// stage('Test vdc-request-monitor') {
// // We don't need this to be an agent. For this component we just need the image to be generated as there are not Unit Tests
// agent {
// dockerfile {
// dir 'vdc-request'
// filename 'Dockerfile.testing'
// reuseNode true
// args '--user 0'
// }
// }
// steps {
// echo "VDC-Request-Monitor Testing"
// sh "export VDC_PORT=80"
// sh "export VDC_ADDRESS=google.de"
// sh "/run.sh &" //start the server
// sh "sleep 25" //wait
// sh "curl -k 'http://127.0.0.1:8000'" //this is the quick test
// }
// }
}
}
stage ('Build - VDC-Request-Monitor Testing') {
agent none
steps {
dir('vdc-request') {
echo "Generation the VDC Request image"
sh "docker build -t \"ditas/vdc-request-monitor\" ."
//TODO: push this image?
}
}
}
// At this point the 3 images were created started and stopped, but they exist (docker images)
// We can create the final artifact, an image with the best of the three
stage ('Main image generation') {
// The final image must be built at the node itsefl, not inside a container
agent none
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 --no-cache -t \"ditas/vdc-base-image\" -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/vdc-base-image:latest..."
sh "docker push ditas/vdc-base-image:latest"
echo "Done "
}
}
// // Deploy the image to the staging seerver
// stage('Image deploy') {
// agent any
// options {
// // Don't need to checkout Git again
// skipDefaultCheckout true
// }
// steps {
// // Deploy to Staging environment calling the deployment script
// // TODO !!!! Edit this file to set the correct iamge tag and port mapping
// sh './jenkins/deploy-staging.sh'
// }
// }
// // Simple test(s) to ensure the base image and all the components are running after deployment
// stage('Component level testing') {
// agent any
// options {
// // Don't need to checkout Git again
// skipDefaultCheckout true
// }
// steps {
// // TODO any vdc-logging test here? A call to the an API method?
// // TODO any vdc-logging test here? A call to the an API method?
// // vdc-request-monitor test - 31.171.247.162 = Staging environment
// // TODO 8000? It is not mapped in the deploy script, in the docker run command
// sh "exec curl -k 'http://31.171.247.162:8000'" // TODO AITOR - deploy an email server to send email on failures
// }
// }
}
}