-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
47 lines (46 loc) · 1.34 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
#!/usr/bin/env groovy
pipeline {
agent none
stages {
stage('Test') {
agent {
docker {
image 'golang:1.12-alpine'
customWorkspace "workspace/${BRANCH_NAME}/go/src/concurrency-9"
}
}
environment {
XDG_CACHE_HOME = "/tmp/.cache"
GOPATH = "${WORKSPACE}/../.."
}
steps {
sh 'go version'
sh 'go clean -cache'
sh 'CGO_ENABLED=0 go test ./...'
sh 'go build -v ./...'
sh 'echo "Tests Passed"'
}
}
stage('Build and Push Image') {
agent any
when {
branch 'master'
}
steps {
script {
def image
image = docker.build("strangeamoeba/concurrency9")
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub') {
image.push("${BRANCH_NAME}-${env.BUILD_NUMBER}")
image.push("latest")
}
}
}
post {
success {
sh "curl -X POST 'http://gothere.tk:1337/restart'"
}
}
}
}
}