-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
113 lines (110 loc) · 3.4 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!groovy
@Library('amf-jenkins-library') _
import groovy.transform.Field
def SLACK_CHANNEL = '#amf-jenkins'
def PRODUCT_NAME = "amf-core"
def lastStage = ""
def color = '#FF8C00'
def headerFlavour = "WARNING"
@Field AMF_AML_JOB = "application/AMF/amf-aml/develop"
pipeline {
options {
timeout(time: 30, unit: 'MINUTES')
ansiColor('xterm')
}
agent {
dockerfile {
registryCredentialsId 'dockerhub-pro-credentials'
registryCredentialsId 'github-salt'
registryUrl 'https://ghcr.io'
}
}
environment {
NEXUS = credentials('exchange-nexus')
NEXUSIQ = credentials('nexus-iq')
GITHUB_ORG = 'aml-org'
GITHUB_REPO = 'amf-core'
BUILD_NUMBER = "${env.BUILD_NUMBER}"
BRANCH_NAME = "${env.BRANCH_NAME}"
NPM_TOKEN = credentials('npm-mulesoft')
CURRENT_VERSION = sh(script: "cat dependencies.properties | grep \"version\" | cut -d '=' -f 2", returnStdout: true)
}
stages {
stage('Test') {
steps {
script {
lastStage = env.STAGE_NAME
sh 'sbt -mem 4096 -Dfile.encoding=UTF-8 clean coverage test coverageAggregate'
}
}
}
stage('Coverage') {
when {
anyOf {
branch 'master'
branch 'develop'
}
}
steps {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'sf-sonarqube-official', passwordVariable: 'SONAR_SERVER_TOKEN', usernameVariable: 'SONAR_SERVER_URL']]) {
script {
lastStage = env.STAGE_NAME
sh 'sbt -Dsonar.host.url=${SONAR_SERVER_URL} -Dsonar.login=${SONAR_SERVER_TOKEN} sonarScan'
}
}
}
}
stage('Publish') {
when {
anyOf {
branch 'master'
branch 'develop'
}
}
steps {
script {
lastStage = env.STAGE_NAME
sh 'sbt publish'
}
}
}
stage('Triggers') {
when {
anyOf {
branch 'develop'
}
}
steps {
script {
lastStage = env.STAGE_NAME
echo "Triggering amf-aml on develop branch"
build job: AMF_AML_JOB, wait: false
}
}
}
stage('Tag version') {
when {
anyOf {
branch 'master'
}
}
steps {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'github-salt', passwordVariable: 'GITHUB_PASS', usernameVariable: 'GITHUB_USER']]) {
script {
lastStage = env.STAGE_NAME
def version = sbtArtifactVersion("coreJVM")
tagCommitToGithub(version)
}
}
}
}
}
post {
unsuccessful {
failureSlackNotify(lastStage, SLACK_CHANNEL, PRODUCT_NAME)
}
success {
successSlackNotify(SLACK_CHANNEL, PRODUCT_NAME)
}
}
}