forked from FoxyLinkIO/FoxyLink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
46 lines (43 loc) · 1.61 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
#!groovy
def PRNumber
def sonarCommand
def version
pipeline {
agent any
environment {
SONAR_TOKEN = credentials('sonar-login')
GITHUB_TOKEN = credentials('sonarqube-silverbulleters')
}
stages {
stage('QASonar') {
steps {
script {
sonarCommand = "\"${SONAR_HOME}/bin/sonar-scanner\" -Dsonar.login=${env.SONAR_TOKEN}"
if (env.BRANCH_NAME == "master") {
echo "Analysing master branch"
} else if (env.BRANCH_NAME == "develop") {
echo "Analysing develop branch"
def conf = new XmlSlurper().parse("${WORKSPACE}/src/Configuration.xml")
conf.children().children().children().each {
if (it.name() == "Version") {
version = it.toString()
}
}
sonarCommand = sonarCommand + " -Dsonar.projectVersion=${version}"
} else if (env.BRANCH_NAME.startsWith("PR-")) {
PRNumber = env.BRANCH_NAME.tokenize("PR-")[0]
sonarCommand = sonarCommand + " -Dsonar.analysis.mode=preview -Dsonar.github.pullRequest=${PRNumber} -Dsonar.github.repository=FoxyLinkIO/FoxyLink -Dsonar.github.oauth=${env.GITHUB_TOKEN}"
}
}
cmd(sonarCommand)
}
}
}
}
def cmd(command) {
if (isUnix()) {
sh "${command}"
} else {
bat "chcp 65001\n${command}"
}
}