-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
51 lines (43 loc) · 1.75 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
node('docker')
{
stage "Container Prep for emp"
echo("The node is up")
def mycontainer = docker.image('elastest/ci-docker-siblings:latest')
mycontainer.pull()
mycontainer.inside("-u jenkins -v /var/run/docker.sock:/var/run/docker.sock:rw")
{
git 'https://github.com/elastest/elastest-monitoring-platform.git'
stage ("Setup") {
try
{
sh "docker rm -f influx"
} catch(e) {
echo "Error: $e"
}
sh "docker run -p 8086:8086 --name influx -d --rm influxdb:1.2.4-alpine"
}
stage "Tests"
echo ("Starting tests")
sh 'cd emp; mvn clean test'
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
stage "Package"
echo ("Packaging")
sh 'cd emp; mvn package -DskipTests'
stage "Archive atifacts"
archiveArtifacts artifacts: 'emp/target/*.jar'
stage "Build image - Package"
echo ("Building EMP Package")
def myimage = docker.build 'elastest/emp:latest'
stage "Run image"
myimage.run()
stage "Publish"
echo ("Publishing")
//this is work arround as withDockerRegistry is not working properly
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'elastestci-dockerhub',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']])
{
sh 'docker login -u "$USERNAME" -p "$PASSWORD"'
myimage.push()
}
}
}