-
Notifications
You must be signed in to change notification settings - Fork 10
/
Jenkinsfile
36 lines (32 loc) · 2.19 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
node('docker') {
stage "Container Prep"
echo("The node is up")
def mycontainer = docker.image('elastest/ci-docker-compose-siblings')
mycontainer.pull()
mycontainer.inside("-u jenkins -v /var/run/docker.sock:/var/run/docker.sock:rw -v ${WORKSPACE}:/home/jenkins/.m2") {
git 'https://github.com/elastest/elastest-monitoring-service'
stage "Test and publish code coverage"
echo ("Publishing code coverage")
sh "mkdir shared || true"
sh 'export PWD=$(pwd)'
sh 'docker run -v ${PWD}/shared:/shared -v ${PWD}/striver-go:/go/src/gitlab.software.imdea.org/felipe.gorostiaga/striver-go -v ${PWD}:/go/src/github.com/elastest/elastest-monitoring-service golang /bin/bash -c "go get github.com/golang/protobuf/proto; go get google.golang.org/grpc; go get google.golang.org/grpc/reflection; cd src/github.com/elastest/elastest-monitoring-service/go_EMS; go test ./... -race -coverprofile=coverage.txt -covermode=atomic; mv coverage.txt /shared"'
sh "curl -s https://codecov.io/bash > shared/curlout.txt"
sh "cd shared; JENKINS_URL= bash <curlout.txt -s - -t ${COB_EMS_TOKEN}; cd ..; rm -rf shared"
stage "Build images - Package"
echo ("Building full version")
sh 'docker build --build-arg GIT_COMMIT=$(git rev-parse HEAD) --build-arg COMMIT_DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%dT%H:%M:%S) . -t elastest/ems:latest'
sh 'docker tag elastest/ems:latest elastest/ems:1.5.0'
def myfullimage = docker.image('elastest/ems:latest');
def myfullimage2 = docker.image('elastest/ems:1.5.0');
stage "Run images"
myfullimage.run()
stage "Publish"
echo ("Publishing")
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'elastestci-dockerhub',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh 'docker login -u "$USERNAME" -p "$PASSWORD"'
myfullimage.push()
myfullimage2.push()
}
}
}