forked from AccelByte/accelbyte-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
79 lines (76 loc) · 2.17 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
72
73
74
75
76
77
78
79
library(
identifier: 'jenkins-shared-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/dhanarab/jenkins-pipeline-library.git'
]
)
)
bitbucketHttpsCredentials = "Bitbucket_Build_AccelByte"
bitbucketPayload = null
bitbucketCommitHref = null
pipeline {
agent {
label "justice-codegen-sdk"
}
stages {
stage('Prepare') {
steps {
script {
if (env.BITBUCKET_PAYLOAD) {
bitbucketPayload = readJSON text: env.BITBUCKET_PAYLOAD
if (bitbucketPayload.pullrequest) {
bitbucketCommitHref = bitbucketPayload.pullrequest.source.commit.links.self.href
}
}
if (bitbucketCommitHref) {
bitbucket.setBuildStatus(bitbucketHttpsCredentials, bitbucketCommitHref, "INPROGRESS", env.JOB_NAME, "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
}
}
}
}
stage('Lint') {
stages {
stage('Lint Commits') {
when {
expression {
return env.BITBUCKET_PULL_REQUEST_LATEST_COMMIT_FROM_TARGET_BRANCH
}
}
agent {
docker {
image 'randondigital/commitlint:3.0'
reuseNode true
}
}
steps {
sh "npm install @commitlint/config-conventional@13.2.0"
sh "commitlint --color false --verbose --from ${env.BITBUCKET_PULL_REQUEST_LATEST_COMMIT_FROM_TARGET_BRANCH}"
}
}
}
}
stage('Build') {
steps {
sh "make build"
}
}
}
post {
success {
script {
if (bitbucketCommitHref) {
bitbucket.setBuildStatus(bitbucketHttpsCredentials, bitbucketCommitHref, "SUCCESSFUL", env.JOB_NAME, "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
}
}
}
failure {
script {
if (bitbucketCommitHref) {
bitbucket.setBuildStatus(bitbucketHttpsCredentials, bitbucketCommitHref, "FAILED", env.JOB_NAME, "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
}
}
}
}
}