-
Notifications
You must be signed in to change notification settings - Fork 678
/
Jenkinsfile
44 lines (44 loc) · 1006 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
pipeline {
agent { label 'linux' }
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
environment {
HEROKU_API_KEY = credentials('darinpope-heroku-api-key')
}
parameters {
string(name: 'APP_NAME', defaultValue: '', description: 'What is the Heroku app name?')
}
stages {
stage('Build') {
steps {
sh 'docker build -t darinpope/java-web-app:latest .'
}
}
stage('Login') {
steps {
sh 'echo $HEROKU_API_KEY | docker login --username=_ --password-stdin registry.heroku.com'
}
}
stage('Push to Heroku registry') {
steps {
sh '''
docker tag darinpope/java-web-app:latest registry.heroku.com/$APP_NAME/web
docker push registry.heroku.com/$APP_NAME/web
'''
}
}
stage('Release the image') {
steps {
sh '''
heroku container:release web --app=$APP_NAME
'''
}
}
}
post {
always {
sh 'docker logout'
}
}
}