-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (74 loc) · 2.58 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
def dockerTags = ['master': 'latest', 'develop': 'develop']
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '30'))
timestamps()
}
agent {
docker {
label 'd3-build-agent'
image 'openjdk:8-jdk-alpine'
args '-v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp'
}
}
stages {
stage('Test') {
steps {
script {
withCredentials([usernamePassword(credentialsId: 'nexus-d3-docker', usernameVariable: 'login', passwordVariable: 'password')]) {
sh """
apk update && apk add docker
docker login --username ${login} --password '${password}' https://nexus.iroha.tech:19002
./gradlew clean build --info
./gradlew dockerfileCreate --info
./gradlew test --info
"""
}
}
}
}
stage('Build') {
steps {
script {
sh "./gradlew clean build --info"
}
}
}
stage('Push artifacts') {
when {
expression { return (env.GIT_BRANCH in dockerTags || env.TAG_NAME) }
}
steps {
script {
withCredentials([usernamePassword(credentialsId: 'nexus-d3-docker', usernameVariable: 'DOCKER_REGISTRY_USERNAME', passwordVariable: 'DOCKER_REGISTRY_PASSWORD')]) {
env.DOCKER_REGISTRY_URL = "https://nexus.iroha.tech:19002"
env.TAG = env.TAG_NAME ? env.TAG_NAME : dockerTags[env.GIT_BRANCH]
sh "./gradlew dockerPush"
}
}
}
}
stage('Sonar') {
steps {
script {
if (env.BRANCH_NAME == 'develop') {
withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]){
sh(script: "./gradlew sonarqube -x test --configure-on-demand \
-Dsonar.links.ci=${BUILD_URL} \
-Dsonar.github.pullRequest=${env.CHANGE_ID} \
-Dsonar.github.disableInlineComments=true \
-Dsonar.host.url=https://sonar.soramitsu.co.jp \
-Dsonar.login=${SONAR_TOKEN} \
")
}
}
}
}
}
}
post {
cleanup {
cleanWs()
}
}
}