forked from Edgio/vflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
87 lines (76 loc) · 2.76 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
pipeline {
agent any
environment {
GITHUB_TOKEN = credentials('GITHUB_TOKEN')
DOCKER_REPOSITORY = "docker.fg"
GIT_VERSION=sh(script: 'git describe --tags --always', returnStdout: true).toString().trim()
}
stages {
stage ("Preparing container for golang") {
agent {
docker {
image "golang"
}
}
stages {
stage ("Unit testing") {
steps {
echo "Unit testing..."
sh "go build ./..."
sh "go install ./..."
sh "go test -v ./... -timeout 1m"
}
}
}
}
stage ("Code quality") {
steps {
echo("Checking code quality....")
script {
def scannerHome = tool 'Sonar Scanner 3.0.0.702';
withSonarQubeEnv {
sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectVersion=$GIT_VERSION"
}
}
}
}
stage("Docker build & publish") {
steps {
script {
dockerImage = docker.build "$DOCKER_REPOSITORY/fg_vflow"
bn = env.BUILD_NUMBER
currentBuild.displayName = "#${bn}:$GIT_VERSION"
dockerImage.push("$GIT_VERSION")
if (env.BRANCH_NAME == "devel") {
dockerImage.push("devel")
}
}
}
}
stage ("Devel deploy") {
when { branch "devel" }
steps {
salt(authtype: 'pam',
clientInterface: local(arguments: 'node.rtbh', blockbuild: true, function: 'state.apply', jobPollTime: 6, target: 'node-1.bohdalec.test.fg', targettype: 'glob'),
credentialsId: '3f36bac7-b50e-42f2-b977-19e352fbd3c7',
saveFile: true,
servername: 'https://salt.test.fg:8000/')
script {
env.WORKSPACE = pwd()
def output = readFile "${env.WORKSPACE}/saltOutput.json"
echo output
echo "Done..."
}
}
}
}
post {
success {
echo "Pipeline success"
}
failure {
echo "Pipeline failed..."
emailext attachLog: true, body: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:\n Check console output at $BUILD_URL to view the results.\n\n', recipientProviders: [culprits()], subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
}
}
}