-
Notifications
You must be signed in to change notification settings - Fork 26
/
Jenkinsfile
71 lines (68 loc) · 3.8 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
pipeline {
agent { label 'Linux-Office03' }
options {
buildDiscarder(logRotator(daysToKeepStr:'10'))
timeout(time: 15, unit: 'MINUTES')
skipDefaultCheckout()
disableConcurrentBuilds()
}
stages {
stage ('Build OpenEdge plugin') {
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 {
withEnv(["MVN_HOME=${tool name: 'Maven 3', type: 'hudson.tasks.Maven$MavenInstallation'}", "JAVA_HOME=${tool name: 'JDK17', type: 'jdk'}"]) {
if ("main" == env.BRANCH_NAME) {
sh "$MVN_HOME/bin/mvn -P release clean deploy -Dgit.commit=\$(git rev-parse --short HEAD)"
mail body: "---", to: "[email protected]", subject: "Release artifact on Sonatype"
} else if ("develop" == env.BRANCH_NAME) {
sh "$MVN_HOME/bin/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_HOME/bin/mvn clean javadoc:javadoc install -Dmaven.test.failure.ignore=true -Dgit.commit=\$(git rev-parse --short HEAD)"
} else {
sh "$MVN_HOME/bin/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(["MVN_HOME=${tool name: 'Maven 3', type: 'hudson.tasks.Maven$MavenInstallation'}", "JAVA_HOME=${tool name: 'JDK17', type: 'jdk'}"]) {
withSonarQubeEnv(installationName: 'SonarCloud') {
if (("main" == env.BRANCH_NAME) || ("develop" == env.BRANCH_NAME)) {
sh "$MVN_HOME/bin/mvn -Dsonar.organization=rssw -Dsonar.branch.name=${env.BRANCH_NAME} sonar:sonar"
} else if (env.BRANCH_NAME.startsWith("hotfix")) {
sh "$MVN_HOME/bin/mvn -Dsonar.organization=rssw -Dsonar.branch.name=${env.BRANCH_NAME} -Dsonar.branch.target=main sonar:sonar"
} else {
sh "$MVN_HOME/bin/mvn -Dsonar.organization=rssw -Dsonar.branch.name=${env.BRANCH_NAME} -Dsonar.branch.target=develop sonar:sonar"
}
}
}
}
}
}
}
post {
unstable {
script {
mail body: "Check console output at ${BUILD_URL}/console", to: "[email protected]", subject: "sonar-openedge build is unstable - Branch ${BRANCH_NAME}"
}
}
failure {
script {
mail body: "Check console output at ${BUILD_URL}/console", to: "[email protected]", subject: "sonar-openedge build failure in Jenkins - Branch ${BRANCH_NAME}"
}
}
fixed {
script {
mail body: "Console output at ${BUILD_URL}/console", to: "[email protected]", subject: "sonar-openedge build is back to normal - Branch ${BRANCH_NAME}"
}
}
}
}