-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.coverity
75 lines (70 loc) · 3.09 KB
/
Jenkinsfile.coverity
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
library(
identifier: 'jenkins-shared-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/dhanarab/jenkins-pipeline-library.git'
]
)
)
jobChannel = env.SLACK_CHANNEL_ACTIVITY_EXTEND_CODEGEN_MODULAR_SDK ? env.SLACK_CHANNEL_ACTIVITY_EXTEND_CODEGEN_MODULAR_SDK : "#activity-justice-codegen-modular-sdk"
pipeline {
agent {
label "extend-builder-batch"
}
stages {
stage('Coverity') {
agent {
docker {
image 'gradle:8.5-jdk8'
args '-u root:root -v cov-analysis:/opt'
reuseNode true
}
}
steps {
script {
//sh "apt update && apt install -y curl git && apt clean"
sh "curl -L '${env.COV_ANALYSIS_TGZ_SHA1_URL}' -o /opt/cov-analysis.tar.gz.sha1"
sh "[ -f /opt/cov-analysis.tar.gz ] || curl -L '${env.COV_ANALYSIS_TGZ_URL}' -o /opt/cov-analysis.tar.gz"
sh "(echo \$(cat /opt/cov-analysis.tar.gz.sha1) /opt/cov-analysis.tar.gz | sha1sum -c) || (echo 'Download corrupted. Please try again!' && rm -f /opt/cov-analysis.tar.gz.sha1 /opt/cov-analysis.tar.gz && exit 100)"
sh "mkdir -p /opt/cov-analysis && rm -rf /opt/cov-analysis/* && tar xf /opt/cov-analysis.tar.gz -C /opt/cov-analysis --strip-components=1"
sh "git config --global --add safe.directory '*' && git clean -xfd"
sh "PATH=/opt/cov-analysis/bin:\$PATH cov-build --dir cov-int bash gradlew build -x test --no-daemon"
sh "tar caf cov-int.tar.gz cov-int"
withCredentials([usernamePassword(credentialsId: 'coverity-accelbyte-java-modular-sdk', passwordVariable: 'COVERITY_TOKEN', usernameVariable: 'COVERITY_EMAIL')]) {
gitCommitHashShort = git.getCommitHashShort()
sh "curl --form token=\$COVERITY_TOKEN --form email=\$COVERITY_EMAIL --form [email protected] --form version='${gitCommitHashShort}' --form description='Automated Coverity Scan' 'https://scan.coverity.com/builds?project=accelbyte-java-modular-sdk'"
}
}
}
}
}
post {
//success {
//script {
//gitRepositoryName = git.getRepositoryName()
//gitBranchName = sh(script: "echo ${env.GIT_BRANCH} | grep -oP '(?<=origin/).+'", returnStdout: true).trim()
//gitCommitHashShort = git.getCommitHashShort()
//gitCommitMessage = git.getCommitMessage()
//
//message = """
// :white_check_mark: <${env.BUILD_URL}|${env.JOB_NAME}-${env.BUILD_NUMBER}> *updated*
//
// |*${gitRepositoryName}:*
// |`${gitBranchName}` `${gitCommitHashShort}`
// |${gitCommitMessage}
//
// |""".stripMargin()
//slackSend(channel: jobChannel, color: '#36B37E', message: message)
//}
//}
failure {
script {
message = """
:no_entry: <${env.BUILD_URL}|${env.JOB_NAME}-${env.BUILD_NUMBER}> *failed*
|""".stripMargin()
slackSend(channel: jobChannel, color: '#FF0000', message: message)
}
}
}
}