forked from CivicActions/civicactions.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.disabled
51 lines (51 loc) · 2.18 KB
/
Jenkinsfile.disabled
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
pipeline {
agent any
triggers {
// Build/deploy master at noon and 6pm PT.
cron(env.BRANCH_NAME == 'master' ? '0 2,20 * * *' : '')
}
options {
buildDiscarder(logRotator(numToKeepStr:'10'))
timeout(time: 15, unit: 'MINUTES')
ansiColor('xterm')
}
environment {
GATSBY_JAZZ_URL = credentials('GATSBY_JAZZ_URL')
}
stages {
stage('Build pull requests') {
when { changeRequest() }
steps {
script {
// Build new image.
sh "docker build -t \"civicactions-internal-it/home:${env.CHANGE_ID}\" --build-arg \"GATSBY_JAZZ_URL=${GATSBY_JAZZ_URL}\" --pull ."
// Remove existing container if it is running.
sh "docker rm -f \"home-${env.CHANGE_ID}\" || true"
// Start container with the right hostname.
sh "docker run --detach --rm --name=\"home-${env.CHANGE_ID}\" \"civicactions-internal-it/home:${env.CHANGE_ID}\""
slackSend channel: 'homesite-bots', message: "PR Review environment ready at http://home-${env.CHANGE_ID}.ci.civicactions.net/"
}
}
}
stage('Build master branch') {
when { branch 'master' }
steps {
script {
// Add a timestamp file to ensure we rebuild the site content
sh "date > .build-timestamp"
docker.withRegistry('https://gcr.io', 'internal-it-k8s-gcr') {
def latestImage = docker.build("civicactions-internal-it/home", "--build-arg GATSBY_JAZZ_URL=${GATSBY_JAZZ_URL} --pull .")
latestImage.push("latest")
latestImage.push("${env.GIT_COMMIT}-${env.BUILD_NUMBER}")
slackSend channel: 'homesite-bots', message: "Master branch built and image pushed successfully to Docker registry"
}
}
}
}
}
post {
failure {
slackSend channel: 'homesite-bots', message: "Build failed, see build log for details: ${env.BUILD_URL}console"
}
}
}