-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJenkinsfile
67 lines (61 loc) · 2.01 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
pipeline {
agent any
stages {
stage('Debug Info') {
steps {
echo "Building branch '${params.BRANCH}'"
sh 'pwd'
sh 'whoami'
sh 'docker info'
}
}
stage('Build') {
steps {
sh './build.sh'
}
}
stage('Test') {
steps {
sh './dockertest.sh'
}
}
// If the branch is master...
stage('Deploy') {
when {
expression { params.BRANCH == 'master' }
}
steps {
sh '''
eval `ssh-agent -s` && ssh-add
if ! grep "$(ssh-keyscan github.com 2>/dev/null)" ~/.ssh/known_hosts > /dev/null; then ssh-keyscan github.com >> ~/.ssh/known_hosts; fi
git remote set-url origin-ssh [email protected]:WillGibson/jenkins-workshop.git || git remote add origin-ssh [email protected]:WillGibson/jenkins-workshop.git
git fetch origin
git checkout master
git pull origin master
git checkout heroku-deploy
git merge master
git push origin-ssh heroku-deploy
'''
// ToDo: Issue #8 - The app doesn't actually work in Heroku
}
}
stage('Smoke Tests') {
when {
expression { params.BRANCH == 'master' }
}
steps {
echo 'ToDo: Run some smoke tests on the deployed app'
echo 'ToDo: Post smoke test failure alert (e.g. in Slack)'
}
}
stage('Rollback on Smoke Test Failure') {
when {
expression { params.BRANCH == 'master' }
}
steps {
echo 'ToDo: Run some smoke tests on the deployed app'
echo 'ToDo: Post rollback alert (e.g. in Slack)'
}
}
}
}