-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
27 lines (26 loc) · 975 Bytes
/
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
node {
def image
stage('Build') {
echo 'Building..'
checkout scm
docker.image('multiarch/qemu-user-static:register').run()
image = docker.build("iotba/rpi-packet_forwarder")
}
stage('Test') {
image.inside {
sh "grep 'ENV PACKET_FORWARDER_VERSION' Dockerfile | tr -d '\r' | awk '//{print \$3}' > version"
sh 'ls -al'
}
}
stage('Deploy') {
def version = readFile 'version'
def imageName = image.imageName()
echo "Deploying version: ${version}"
sh "docker tag ${imageName} ${imageName}:${version}"
withCredentials([usernamePassword(credentialsId: 'hub.docker.com', passwordVariable: 'DOCKER_PASS', usernameVariable: 'DOCKER_USER')]) {
sh "docker login -u='$DOCKER_USER' -p='$DOCKER_PASS'"
sh "docker push ${imageName}:${version}"
sh "docker push ${imageName}"
}
}
}