-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-pr-checks
53 lines (44 loc) · 2.19 KB
/
Jenkinsfile-pr-checks
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
def gitCommit = "${params.commit}"
def postStatus(state, context, gitCommit) {
def description = "Jenkins pipeline for React Common"
def payload = "{\"state\": \"${state}\", \"description\": \"${description}\", \"context\": \"${context}\", \"target_url\": \"${build_url}\""
sh "/usr/bin/curl -s -X POST -H 'Authorization: token ${GITHUB_TOKEN}' -d '${payload}' https://api.github.com/repos/Wikia/react-common/statuses/${gitCommit}"
}
node('qa-executors') {
stage('Clone repo and start PR checks') {
git credentialsId: 'bd3cf712-39a7-4b16-979e-ff86208ab2ea', url: '[email protected]:Wikia/react-common.git', branch: "${params.branch}"
nodejs('v12 LTS') {
currentBuild.description = "branch: ${params.branch}, commit: ${params.commit}, PR: ${params.pull_num}"
stage('Install dependencies') {
postStatus("pending", "1. Install dependencies", gitCommit)
try {
sh 'yarn install --frozen-lockfile'
postStatus("success", "1. Install dependencies", gitCommit)
} catch (e) {
postStatus("failure", "1. Install dependencies", gitCommit)
error 'FAIL' // sh "exit 1" - this makes this stage fail
}
}
stage('Run Linter') {
postStatus("pending", "2. Run Linter", gitCommit)
try {
sh 'yarn ci'
postStatus("success", "2. Run Linter", gitCommit)
} catch (e) {
postStatus("failure", "2. Run Linter", gitCommit)
error 'FAIL' // sh "exit 1" - this makes this stage fail
}
}
stage('Run tests with coverage') {
postStatus("pending", "3. Run tests & coverage", gitCommit)
try {
sh 'yarn coverage'
postStatus("success", "3. Run tests & coverage", gitCommit)
} catch (e) {
postStatus("failure", "3. Run tests & coverage", gitCommit)
error 'FAIL' // sh "exit 1" - this makes this stage fail
}
}
}
}
}