-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
105 lines (103 loc) · 3.41 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
/*
* (C) Copyright 2019 Nuxeo (http://nuxeo.com/) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Contributors:
* Nelson Silva <[email protected]>
*/
properties([
[$class: 'GithubProjectProperty', projectUrlStr: 'https://github.com/nuxeo/nuxeo-elements/'],
[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', daysToKeepStr: '60', numToKeepStr: '60', artifactNumToKeepStr: '5']],
])
void setGitHubBuildStatus(String context, String message, String state) {
step([
$class: 'GitHubCommitStatusSetter',
reposSource: [$class: 'ManuallyEnteredRepositorySource', url: 'https://github.com/nuxeo/nuxeo-elements'],
contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: context],
statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', message: message, state: state]]],
])
}
pipeline {
agent {
label "jenkins-nodejs-nuxeo"
}
stages {
stage('Install dependencies and run lint') {
steps {
container('nodejs') {
echo """
---------------------------------
Install dependencies and run lint
---------------------------------"""
script {
def nodeVersion = sh(script: 'node -v', returnStdout: true).trim()
echo "node version: ${nodeVersion}"
}
sh 'npm install --no-package-lock'
sh 'npm run bootstrap -- --no-ci'
sh 'npm run lint'
}
}
post {
success {
setGitHubBuildStatus('install', 'Install dependencies and run lint', 'SUCCESS')
}
failure {
setGitHubBuildStatus('install', 'Install dependencies and run lint', 'FAILURE')
}
}
}
stage('Run tests') {
steps {
container('nodejs') {
echo """
---------
Run tests
---------"""
sh 'npm run test -- --debugBrowsers=ChromeHeadlessNoSandbox'
}
}
post {
success {
setGitHubBuildStatus('webpack', 'Webpack build', 'SUCCESS')
}
failure {
setGitHubBuildStatus('webpack', 'Webpack build', 'FAILURE')
}
}
}
}
post {
success {
container('nodejs') {
// publish
script {
if (BRANCH_NAME == 'master') {
def token = sh(script: 'jx step credential -s jenkins-npm-token -k token', returnStdout: true).trim()
sh "echo '//nexus/repository/npmjs-nuxeo/:_authToken=${token}' >> ~/.npmrc"
sh "npx lerna exec --ignore @nuxeo/nuxeo-elements-storybook -- npm publish --registry=http://nexus/repository/npmjs-nuxeo/ --tag SNAPSHOT"
}
}
}
}
always {
script {
if (BRANCH_NAME == 'master') {
// update JIRA issue
// step([$class: 'JiraIssueUpdater', issueSelector: [$class: 'DefaultIssueSelector'], scm: scm])
}
}
}
}
}