-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
71 lines (69 loc) · 2.12 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
68
69
70
71
def vers
def outFile
def release = false
pipeline {
agent any
tools {
go 'Go 1.21'
maven 'Mvn'
}
environment {
NEXUS_CREDS = credentials('Cantara-NEXUS')
}
stages {
stage("pre") {
steps {
script {
if (env.TAG_NAME) {
vers = "${env.TAG_NAME}"
release = true
} else {
vers = "${env.GIT_COMMIT}"
}
outFile = "christmasbeer-${vers}"
echo "New file: ${outFile}"
}
}
}
stage("test") {
steps {
script {
testApp()
}
}
}
stage("build") {
steps {
script {
echo "V: ${vers}"
echo "File: ${outFile}"
buildApp(outFile, vers)
}
}
}
stage("deploy") {
steps {
script {
echo 'deplying the application...'
echo "deploying version ${vers}"
if (release) {
sh 'curl -v -u $NEXUS_CREDS '+"--upload-file ${outFile} https://mvnrepo.cantara.no/content/repositories/releases/no/cantara/justforfun/christmasbeer/${vers}/${outFile}"
} else {
sh 'curl -v -u $NEXUS_CREDS '+"--upload-file ${outFile} https://mvnrepo.cantara.no/content/repositories/snapshots/no/cantara/justforfun/christmasbeer/${vers}/${outFile}"
}
sh "rm ${outFile}"
}
}
}
}
}
def testApp() {
echo 'testing the application...'
sh './testRecursive.sh'
}
def buildApp(outFile, vers) {
echo 'building the application...'
sh 'ls'
sh "CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \"-X 'github.com/cantara/gober/webserver/health.Version=${vers}' -X 'github.com/cantara/gober/webserver/health.BuildTime=\$(date)'\" -o ${outFile}"
sh 'ls'
}