-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
30 lines (30 loc) · 904 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
28
29
30
pipeline
{
agent { label 'builder' }
environment
{
VERSION_NUMBER = '7.4'
IMAGE_VERSION = "${GIT_BRANCH == "master" ? VERSION_NUMBER : VERSION_NUMBER+"-"+GIT_BRANCH}"
DOCKER_HUB = credentials("dockerhub-creds")
}
stages
{
stage('build') { steps { script { sh("docker build -t nschultz/sonarqube:${IMAGE_VERSION} --build-arg SONAR_VERSION_ARG=${VERSION_NUMBER} .") } } }
stage('push')
{
when { branch 'master' }
steps
{
script
{
sh """
#!/bin/bash
docker login -u ${DOCKER_HUB_USR} -p ${DOCKER_HUB_PSW}
docker push nschultz/sonarqube:${IMAGE_VERSION}
docker logout
"""
}
}
}
}
}