-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathJenkinsfile
46 lines (37 loc) · 1012 Bytes
/
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
pipeline {
agent any
parameters {
choice(choices: ['Node 17', 'Node 18'], name: 'NODE_INSTALLATION_NAME')
}
environment {
TOKEN = credentials("herokuToken")
tag = "registry.heroku.com/joke-jenkins/web"
}
stages {
stage('build-test') {
steps {
nodejs(nodeJSInstallationName: "${params.NODE_INSTALLATION_NAME}") {
sh 'node -v'
sh 'npm install'
sh 'npm run build'
sh 'npm test'
}
}
}
stage('deploy') {
steps {
script {
def image = docker.build('mohammaddocker/joke-app-jenkins')
docker.withRegistry('https://registry.hub.docker.com', 'dockerId') {
def dockerImage = image
dockerImage.push('latest')
}
docker.withRegistry('https://registry.heroku.com', 'herokuId') {
sh "docker tag mohammaddocker/joke-app-jenkins ${tag}:latest"
sh "docker push ${tag}:latest"
}
}
}
}
}
}