-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
executable file
·108 lines (98 loc) · 2.83 KB
/
Jenkinsfile
File metadata and controls
executable file
·108 lines (98 loc) · 2.83 KB
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
106
107
108
properties([pipelineTriggers([githubPush()])])
pipeline {
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 40, unit: 'MINUTES')
}
agent {
kubernetes {
inheritFrom 'generic'
containerTemplates([
containerTemplate(name: 'nodejs', image: "479720515435.dkr.ecr.us-east-1.amazonaws.com/flowcommerce/node18_builder:latest", resourceRequestCpu: '1', resourceRequestMemory: '4Gi', command: 'cat', ttyEnabled: true, runAsUser: '1000'),
])
}
}
environment {
ORG = 'flowcommerce'
NPM_TOKEN = credentials('jenkins-npm-bypass-2fa-token')
}
stages {
stage('Checkout') {
steps {
checkoutWithTags scm
script {
VERSION = new flowSemver().calculateSemver() //requires checkout
}
}
}
stage('Install & Build') {
environment {
NPM_TOKEN = credentials('jenkins-npm-bypass-2fa-token')
}
when { not { branch 'main' } }
steps {
container('nodejs') {
script {
sh(script: 'node --version')
sh(script: 'npm --version')
sh(script: 'echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc')
sh(script: 'NODE_ENV=development npm ci')
}
}
}
}
stage('Lint') {
when { not { branch 'main' } }
steps {
container('nodejs') {
script {
sh(script: 'npm run lint')
}
}
}
}
stage('Commit SemVer tag') {
when { branch 'main' }
steps {
script {
VERSION = new flowSemver().calculateSemver()
new flowSemver().commitSemver(VERSION)
}
}
}
stage('Build new release') {
environment {
NPM_TOKEN = credentials('jenkins-npm-bypass-2fa-token')
}
when { branch 'main' }
steps {
container('nodejs') {
withCredentials([
usernamePassword(
credentialsId: 'jenkins-x-github',
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD'
)
]) {
script {
semver = VERSION.printable()
sh """
node --version
npm --version
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
NODE_ENV=development npm ci
npm run build
mv dist/js/main.css dist/css/main.css
sed -i 's/APP_VERSION/$semver/g' dist/index.html
aws s3 sync dist/css s3://track.flow.io/test/css/$semver
aws s3 sync dist/js s3://track.flow.io/test/js/$semver
aws s3 cp dist/index.html s3://track.flow.io/test
"""
}
}
}
}
}
}
}