-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathJenkinsfile
More file actions
96 lines (91 loc) · 4.6 KB
/
Jenkinsfile
File metadata and controls
96 lines (91 loc) · 4.6 KB
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
pipeline {
agent { label 'Linux-Office03' }
options {
buildDiscarder(logRotator(daysToKeepStr:'10'))
timeout(time: 15, unit: 'MINUTES')
skipDefaultCheckout()
disableConcurrentBuilds()
}
stages {
stage ('👷 Build') {
environment {
OP_CLI_PATH = '/usr/local/bin/'
MAVEN_GPG_PASSPHRASE = 'op://Jenkins/GPG/password'
SONATYPE_USERNAME = 'op://Jenkins/Sonatype/username'
SONATYPE_PASSWORD = 'op://Jenkins/Sonatype/password'
}
steps {
checkout([$class: 'GitSCM', branches: scm.branches, extensions: scm.extensions + [[$class: 'CleanCheckout']], userRemoteConfigs: scm.userRemoteConfigs])
checkout([$class: 'GitSCM', branches: scm.branches, extensions: scm.extensions + [[$class: 'CleanCheckout']], userRemoteConfigs: [[credentialsId: scm.userRemoteConfigs.credentialsId[0], url: scm.userRemoteConfigs.url[0], refspec: '+refs/heads/main:refs/remotes/origin/main']] ])
checkout([$class: 'GitSCM', branches: scm.branches, extensions: scm.extensions + [[$class: 'CleanCheckout']], userRemoteConfigs: [[credentialsId: scm.userRemoteConfigs.credentialsId[0], url: scm.userRemoteConfigs.url[0], refspec: '+refs/heads/develop:refs/remotes/origin/develop']] ])
script {
sh '> author.txt git log --format="%ae" -n 1'
withEnv(["PATH+MVN=${tool name: 'Maven 3', type: 'maven'}/bin", "JAVA_HOME=${tool name: 'JDK17', type: 'jdk'}"]) {
if ("main" == env.BRANCH_NAME) {
withSecrets() {
configFileProvider([configFile(fileId: 'MvnSettingsRSSW', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn -s ${MAVEN_SETTINGS} -P release clean deploy -Dgit.commit=\$(git rev-parse --short HEAD)'
}
}
mail body: "https://central.sonatype.com/publishing/deployments", to: "jenkins-reports@riverside-software.fr", subject: "sonar-openedge - Publish artifact on Central"
} else if ("develop" == env.BRANCH_NAME) {
sh "mvn clean javadoc:javadoc deploy -Dmaven.test.failure.ignore=true -Dgit.commit=\$(git rev-parse --short HEAD)"
} else if (env.BRANCH_NAME.startsWith("release") || env.BRANCH_NAME.startsWith("hotfix")) {
sh "mvn clean javadoc:javadoc install -Dmaven.test.failure.ignore=true -Dgit.commit=\$(git rev-parse --short HEAD)"
} else {
sh "mvn clean verify -Dmaven.test.failure.ignore=true -Dgit.commit=\$(git rev-parse --short HEAD)"
}
}
}
step([$class: 'Publisher', reportFilenamePattern: '**/target/surefire-reports/testng-results.xml'])
archiveArtifacts artifacts: '**/openedge-plugin/target/sonar-openedge-plugin-*.jar'
}
}
stage ('🔍 SonarQube analysis') {
steps {
script {
withEnv(["PATH+MVN=${tool name: 'Maven 3', type: 'maven'}/bin", "JAVA_HOME=${tool name: 'JDK17', type: 'jdk'}"]) {
withSonarQubeEnv(credentialsId: 'SQToken', installationName: 'RSSW') {
if (("main" == env.BRANCH_NAME) || ("develop" == env.BRANCH_NAME)) {
sh "mvn -Dsonar.branch.name=${env.BRANCH_NAME} sonar:sonar"
} else if (env.BRANCH_NAME.startsWith("hotfix")) {
sh "mvn -Dsonar.branch.name=${env.BRANCH_NAME} -Dsonar.newCode.referenceBranch=main -Dsonar.branch.target=main sonar:sonar"
} else {
sh "mvn -Dsonar.branch.name=${env.BRANCH_NAME} -Dsonar.newCode.referenceBranch=develop -Dsonar.branch.target=develop sonar:sonar"
}
}
}
}
}
}
stage('🦺 Quality Gate') {
steps {
timeout(time: 5, unit: 'MINUTES') {
warnError('Failed quality gate') {
waitForQualityGate abortPipeline: true
}
}
}
}
}
post {
unstable {
script {
def author = readFile('author.txt').trim()
mail body: "Check console output at ${BUILD_URL}/console", to: "jenkins-reports@riverside-software.fr,${author}", subject: "sonar-openedge ${BRANCH_NAME} build is unstable"
}
}
failure {
script {
def author = readFile('author.txt').trim()
mail body: "Check console output at ${BUILD_URL}/console", to: "jenkins-reports@riverside-software.fr,${author}", subject: "sonar-openedge ${BRANCH_NAME} build failure"
}
}
fixed {
script {
def author = readFile('author.txt').trim()
mail body: "Console output at ${BUILD_URL}/console", to: "jenkins-reports@riverside-software.fr,${author}", subject: "sonar-openedge ${BRANCH_NAME} build is back to normal"
}
}
}
}