-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
68 lines (59 loc) · 1.95 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
MAIN_BRANCH = 'master'
IS_MASTER_BUILD = (env.BRANCH_NAME == MAIN_BRANCH)
node(label: 'Small') {
catchError {
withDockerRegistry(registry: [credentialsId: 'docker-hub', url: 'https://index.docker.io/v1/']) {
docker.image('vingle/suspicious-serverless:nodejs8.10').pull()
withDockerContainer([image: 'vingle/suspicious-serverless:nodejs8.10']) {
stage('Checkout SCM') {
checkout scm
step([$class: 'GitHubSetCommitStatusBuilder'])
}
stage('Check Dependencies') {
env.npm_config_cache = "./npm"
sh 'npm install --quiet'
}
stage('Lint') {
sh 'npm run lint'
}
stage('Test') {
sh 'npm run test'
}
if (IS_MASTER_BUILD) {
withCredentials([
[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'jenkins iam',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]
]) {
stage('deploy:stage') {
sh 'npm run deploy:stage'
sh 'npm run deploy:stage -- --region=ap-northeast-2'
}
stage('deploy:prod') {
sh 'npm run deploy:prod'
sh 'npm run deploy:prod -- --region=ap-northeast-2'
}
}
}
}
}
currentBuild.result = 'SUCCESS'
}
step([
$class: 'GitHubCommitStatusSetter',
errorHandlers: [
[$class: 'ShallowAnyErrorHandler']
],
statusResultSource: [
$class: 'ConditionalStatusResultSource',
results: [
[$class: 'BetterThanOrEqualBuildResult', result: 'SUCCESS', state: 'SUCCESS', message: currentBuild.description],
[$class: 'BetterThanOrEqualBuildResult', result: 'FAILURE', state: 'FAILURE', message: currentBuild.description],
[$class: 'AnyBuildResult', state: 'FAILURE', message: 'Loophole']
]
]
])
}