-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
55 lines (52 loc) · 1.47 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
pipeline {
// Each stage specify its own agent
agent none
// Setup common job properties
options {
ansiColor('xterm')
timestamps()
timeout(time: 240, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '10'))
preserveStashes()
}
// Build stages
stages {
stage('Gridsome Builder: Build') {
agent { label 'gridsome_builder' }
steps {
checkoutSrcs()
withCredentials([
string(credentialsId: 'GRIDSOME_SHOPIFY_STOREFRONT_TOKEN', variable: 'GRIDSOME_SHOPIFY_STOREFRONT_TOKEN'),
string(credentialsId: 'CONTENTFUL_TOKEN', variable: 'CONTENTFUL_TOKEN'),
string(credentialsId: 'CONTENTFUL_SPACE', variable: 'CONTENTFUL_SPACE'),
string(credentialsId: 'NETLIFY_AUTH_TOKEN', variable: 'NETLIFY_AUTH_TOKEN'),
string(credentialsId: 'NETLIFY_SITE_ID', variable: 'NETLIFY_SITE_ID')
]) {
sh '''
#!/bin/bash
ln -sf $HOME/node_modules/ .
export PATH=$HOME/npm-global/bin:$PATH
export GRIDSOME_SHOPIFY_STOREFRONT=puppyous
export CONTENTFUL_ENVIRONMENT=master
gridsome build
netlify deploy
'''
}
}
}
}
}
// check out source code from git
def checkoutSrcs() {
retry(5) {
try {
timeout(time: 2, unit: 'MINUTES') {
checkout scm
sh 'git submodule update --init'
}
} catch (exc) {
deleteDir()
error "Failed to fetch source codes"
}
}
}