|
1 | | -#! groovy |
| 1 | +#!groovy |
2 | 2 | library 'pipeline-library' |
3 | 3 |
|
4 | | -def nodeVersion = '8.9.1' |
5 | | -def MAINLINE_BRANCH_REGEXP = /master|\d_\d_(X|\d)/ // a branch is considered mainline if 'master' or like: 1_7_X |
6 | | -def isPublishable = false // used to determine if we should publish |
7 | | -timestamps { |
8 | | - node('osx && npm-publish') { |
9 | | - def packageVersion = '' |
10 | | - stage('Checkout') { |
11 | | - // checkout scm |
12 | | - // Hack for JENKINS-37658 - see https://support.cloudbees.com/hc/en-us/articles/226122247-How-to-Customize-Checkout-for-Pipeline-Multibranch |
13 | | - checkout([ |
14 | | - $class: 'GitSCM', |
15 | | - branches: scm.branches, |
16 | | - extensions: scm.extensions + [[$class: 'CleanBeforeCheckout']], |
17 | | - userRemoteConfigs: scm.userRemoteConfigs |
18 | | - ]) |
19 | | - |
20 | | - packageVersion = jsonParse(readFile('package.json'))['version'] |
21 | | - isPublishable = (env.BRANCH_NAME ==~ MAINLINE_BRANCH_REGEXP) |
22 | | - currentBuild.displayName = "#${packageVersion}-${currentBuild.number}" |
23 | | - } |
24 | | - |
25 | | - nodejs(nodeJSInstallationName: "node ${nodeVersion}") { |
26 | | - ansiColor('xterm') { |
27 | | - timeout(15) { |
28 | | - stage('Build') { |
29 | | - // Install yarn if not installed |
30 | | - if (sh(returnStatus: true, script: 'which yarn') != 0) { |
31 | | - sh 'npm install -g yarn' |
32 | | - } |
33 | | - sh 'yarn install' |
34 | | - try { |
35 | | - withEnv(['TRAVIS=true', 'JUNIT_REPORT_PATH=junit_report.xml']) { |
36 | | - sh 'yarn test' |
37 | | - } |
38 | | - } catch (e) { |
39 | | - throw e |
40 | | - } finally { |
41 | | - junit 'junit_report.xml' |
42 | | - } |
43 | | - fingerprint 'package.json' |
44 | | - // Only tag publishable branches |
45 | | - if (isPublishable) { |
46 | | - pushGitTag(name: packageVersion, message: "See ${env.BUILD_URL} for more information.", force: true) |
47 | | - } |
48 | | - } // stage |
49 | | - } // timeout |
50 | | - |
51 | | - stage('Security') { |
52 | | - // Clean up and install only production dependencies |
53 | | - sh 'yarn install --production' |
54 | | - |
55 | | - // Scan for NSP and RetireJS warnings |
56 | | - sh 'yarn global add nsp' |
57 | | - sh 'nsp check --output summary --warn-only' |
58 | | - |
59 | | - sh 'yarn global add retire' |
60 | | - sh 'retire --exitwith 0' |
61 | | - |
62 | | - // TODO Run node-check-updates |
63 | | - |
64 | | - step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Node Security Project Vulnerabilities'], [parserName: 'RetireJS']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: '']) |
65 | | - } // stage |
66 | | - |
67 | | - stage('Publish') { |
68 | | - // only publish master and trigger downstream |
69 | | - if (isPublishable) { |
70 | | - sh 'npm publish' |
71 | | - } |
72 | | - } // stage |
73 | | - |
74 | | - stage('JIRA') { |
75 | | - if (isPublishable) { |
76 | | - // update affected tickets, create and release version |
77 | | - updateJIRA('TIMOB', "ioslib ${packageVersion}", scm) |
78 | | - } // if |
79 | | - } // stage(JIRA) |
80 | | - } // ansiColor |
81 | | - } //nodejs |
82 | | - } // node |
83 | | -} // timestamps |
| 4 | +buildNPMPackage { |
| 5 | + labels = 'osx && git && npm-publish' |
| 6 | + // nodeVersion = '8.9.1' |
| 7 | + projectKey = 'TIMOB' |
| 8 | + // updateJIRATickets = true |
| 9 | +} |
0 commit comments