/
Jenkinsfile
63 lines (56 loc) · 1.56 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
pipeline {
agent {
label 'master'
}
environment {
registry = 'wdalmut/mynode'
registryCredentials = 'dockerhub'
}
parameters {
booleanParam(defaultValue: true, description: 'My User Flag', name: 'userFlag')
}
stages {
stage('Prepare') {
steps {
withCredentials([string(credentialsId: 'MY_SECRET', variable: 'APP_SECRET'), file(credentialsId: 'my-config', variable: 'MY_CONFIG')]) {
sh "echo ${env.APP_SECRET}"
sh "cat ${env.MY_CONFIG}"
sh "#cp ${env.MY_CONFIG} secret.txt"
sh "echo commit-${env.GIT_COMMIT} > commit.txt"
}
}
}
stage('Build') {
agent {
docker { image 'node:14-alpine' }
}
steps {
sh 'node --version'
sh 'npm i'
sh './node_modules/.bin/jasmine'
}
}
stage('Build Image') {
when {
branch 'master'
}
steps {
script {
dockerImage = docker.build "${registry}:${BUILD_NUMBER}"
}
}
}
stage('Push Image') {
when {
branch 'master'
}
steps {
script {
docker.withRegistry('', registryCredentials) {
dockerImage.push()
}
}
}
}
}
}