-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathJenkinsfile
63 lines (51 loc) · 1.44 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
#!/usr/bin/env groovy
Map<String, Object> props = [
credentialsId : 'github',
nodeVersion : 'node-10'
]
def git
def npm
fileLoader.withGit('https://git.aurora.skead.no/scm/ao/aurora-pipeline-scripts.git', 'v7') {
git = fileLoader.load('git/git')
npm = fileLoader.load('node.js/npm')
}
node {
if (env.BRANCH_NAME != "master") {
currentBuild.result = 'ABORTED'
error('Branch is not master')
}
if (props.nodeVersion) {
echo 'Using Node version: ' + props.nodeVersion
npm.setVersion(props.nodeVersion)
}
stage('Clean Workspace') {
deleteDir()
sh 'ls -lah'
}
stage('Checkout') {
checkout scm
}
stage('Install dependencies') {
npm.run('ci')
}
stage('Build') {
npm.build()
}
stage('Deploy to GitHub') {
try {
withCredentials([usernamePassword(credentialsId: props.credentialsId, usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD')]) {
git.setGitConfig()
sh("git config --global credential.https://github.saobby.my.eu.org.username ${env.GIT_USERNAME}")
sh("git config --global credential.helper '!echo password=\$GIT_PASSWORD; echo'")
sh("GIT_ASKPASS=true npm run deploy")
}
} finally {
sh("git config --global --unset credential.https://github.saobby.my.eu.org.username")
sh("git config --global --unset credential.helper")
}
}
stage('Clear workspace') {
step([$class: 'WsCleanup'])
}
}