-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
93 lines (89 loc) · 3.17 KB
/
Copy pathJenkinsfile
File metadata and controls
93 lines (89 loc) · 3.17 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
pipeline {
agent { label 'master' }
environment {
DOCKER_RELEASE_TAG=''
DOCKER_RELEASE_TAG_RISKDB=''
branch_name=''
projectKey=''
projectName=''
}
tools {
maven 'Maven 3.5.4'
}
options {
timestamps()
timeout(time: 30)
// skipDefaultCheckout()
skipStagesAfterUnstable()
}
stages {
stage('Sonarqube-MR') {
when {
expression {
return !(GIT_BRANCH ==~ /^PR-\d+$/)
}
beforeAgent true
}
environment {
scannerHome = tool name: 'RSSONAR', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
}
steps {
script {
def BRANCH = sh(returnStdout: true, script: 'echo /"/$/{env.GIT_BRANCH/}"').trim()
BRANCH_NAME=BRANCH
def reponame = sh(returnStdout: true, script: 'echo /"/$/{env.GIT_URL/}/"').trim().replaceAll('https://github.com/risksense/', '').replaceAll('.git', '')
PROJECTKEY=reponame
PROJECTNAME=reponame
}
sh "printenv | sort"
}
}
stage('SONARQUBE-PR') {
when {
expression {
return (GIT_BRANCH ==~ /^PR-\d+$/)
}
beforeAgent true
}
environment {
scannerHome = tool name: 'RSSONAR', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
}
steps {
script {
def reponame = sh(returnStdout: true, script: 'echo /$/"/{env.GIT_URL/}/"').trim().replaceAll('https://github.com/risksense/', '').replaceAll('.git', '')
PROJECTKEY=reponame
PROJECTNAME=reponame
def org = sh(returnStdout: true, script: 'echo /$/"/{env.GIT_URL/}/"').trim().replaceAll('https://github.com/', '').replaceAll('.git', '')
ORG_NAME=org
}
sh "printenv | sort"
sh "echo ${env.GIT_URL}"
sh "echo ${env.GIT_BRANCH}"
sh 'echo "PR sonar build"'
gitHubPRStatus githubPRMessage('Qualitygate Scan started')
}
post {
success {
script {
def reponame = sh(returnStdout: true, script: 'echo /$/"/{env.GIT_URL/}/"').trim().replaceAll('https://github.com/risksense/', '').replaceAll('.git', '')
PROJECTKEY=reponame
PROJECTNAME=reponame
def org = sh(returnStdout: true, script: 'echo /$/"/{env.GIT_URL/}/"').trim().replaceAll('https://github.com/', '').replaceAll('.git', '')
ORG_NAME=org
}
githubNotify account: 'kiransre', context: 'QualityGate', credentialsId: 'Github', description: 'Qualitygate is finished', gitApiUrl: '', repo: "$ORG_NAME", sha: "${env.GIT_COMMIT}", status: 'SUCCESS', targetUrl: ''
}
failure {
script {
def reponame = sh(returnStdout: true, script: 'echo /$/"/{env.GIT_URL/}/"').trim().replaceAll('https://github.com/risksense/', '').replaceAll('.git', '')
PROJECTKEY=reponame
PROJECTNAME=reponame
def org = sh(returnStdout: true, script: 'echo /$/"/{env.GIT_URL/}/"').trim().replaceAll('https://github.com/', '').replaceAll('.git', '')
ORG_NAME=org
}
githubNotify account: 'kiransre', context: 'QualityGate', credentialsId: 'Github', description: 'Qualitygate is failed', gitApiUrl: '', repo: "$ORG_NAME", sha: "${env.GIT_COMMIT}", status: 'PENDING', targetUrl: ''
}
}
}
}
}