-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
111 lines (108 loc) · 3.42 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
library(
identifier: 'jenkins-shared-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/dhanarab/jenkins-pipeline-library.git'
]
)
)
bitbucketCredentials = "bitbucket-build-extend-https"
bitbucketCredentialsSsh = "bitbucket-build-extend-ssh"
bitbucketPayload = null
bitbucketCommitHref = null
pipeline {
agent {
label "extend-builder-ci"
}
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(bitbucketCredentials, bitbucketCommitHref, "INPROGRESS", env.JOB_NAME, "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
}
}
}
}
stage("Parallel") {
parallel {
stage('Lint') {
stages {
stage('Lint Commits') {
when {
expression {
return env.BITBUCKET_PULL_REQUEST_LATEST_COMMIT_FROM_TARGET_BRANCH
}
}
agent {
docker {
image 'commitlint/commitlint:19.3.1'
args '--entrypoint='
reuseNode true
}
}
steps {
sh "git config --add safe.directory '*'"
sh "commitlint --color false --verbose --from ${env.BITBUCKET_PULL_REQUEST_LATEST_COMMIT_FROM_TARGET_BRANCH}"
}
}
stage('Lint Spec') {
steps {
sh "[ -s spec/openapi-2.0-vendor-extensions.md ]" // Make sure OpenAPI 2.0 vendor extensions is present
sh "[ -s spec/TIMESTAMP ]" // Make sure TIMESTAMP file is present
}
}
stage('Lint Code') {
steps {
sh "[ -s codegen.txt ]" // Make sure codegen.txt file is present
//sh "make lint-mod-outdated"
sh "make lint"
}
}
}
}
stage('Build') {
steps {
sh "make samples"
}
}
stage('Test') {
stages {
stage('Core Tests') {
steps {
sshagent(credentials: [bitbucketCredentialsSsh]) {
sh "rm -rf .justice-codegen-sdk-mock-server"
sh "git clone --depth 1 [email protected]:accelbyte/justice-codegen-sdk-mock-server.git .justice-codegen-sdk-mock-server"
}
sh "make test_core SDK_MOCK_SERVER_PATH=.justice-codegen-sdk-mock-server"
}
}
}
}
}
}
}
post {
success {
script {
if (bitbucketCommitHref) {
bitbucket.setBuildStatus(bitbucketCredentials, bitbucketCommitHref, "SUCCESSFUL", env.JOB_NAME, "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
}
}
}
failure {
script {
if (bitbucketCommitHref) {
bitbucket.setBuildStatus(bitbucketCredentials, bitbucketCommitHref, "FAILED", env.JOB_NAME, "${env.JOB_NAME}-${env.BUILD_NUMBER}", "Jenkins", "${env.BUILD_URL}console")
}
}
}
}
}