UNPKG

2.51 kBPlain TextView Raw
1node {
2 checkout scm
3
4 ansiColor('xterm') {
5 try {
6 setBuildStatus("Build Pending", "PENDING");
7
8 sh "npm install"
9
10 stage('Test') {
11 sh "npm test"
12 }
13
14 stage('Lint') {
15 sh "npm run lint"
16 }
17
18 // This is going to keep failing until we fix stuff...
19 // stage('Audit') {
20 // sh "npm audit"
21 // }
22
23 // // We want to tag, push, and deploy when we push to master
24 // if ( env.BRANCH_NAME == "master" ) {
25 // stage('Push') {
26
27 // // Login to AWS ECR
28 // sh '$(aws ecr get-login --no-include-email --region us-east-2)'
29
30 // // Push container to remote with :latest tag
31 // sh "docker tag ${container} ${registryUrl}/${containerName}:latest"
32 // sh "docker push ${registryUrl}/${containerName}:latest"
33
34 // // Tag remote image with :branch-buildNumber
35 // sh "docker tag ${registryUrl}/${containerName}:latest ${registryUrl}/${container}"
36 // sh "docker push ${registryUrl}/${container}"
37
38 // // Tag remote image with commit sha
39 // def gitCommitSHA = sh (script: "git rev-parse --short HEAD | tail -n1 | tr -d '\n'", returnStdout: true)
40 // sh "docker tag ${registryUrl}/${containerName}:latest ${registryUrl}/${containerName}:${gitCommitSHA}"
41 // sh "docker push ${registryUrl}/${containerName}:${gitCommitSHA}"
42 // }
43
44 // stage('QA Deploy') {
45 // // TODO
46 // }
47 // }
48
49 setBuildStatus("Build Succeeded", "SUCCESS");
50 } catch (e) {
51 setBuildStatus("Build failed", "FAILED");
52 throw e
53 }
54 }
55}
56
57void setBuildStatus(String message, String state) {
58 step([
59 $class: "GitHubCommitStatusSetter",
60 reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/pactsafe/pactsafe-react-sdk"],
61 contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
62 errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
63 statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
64 ]);
65}
\No newline at end of file