-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
86 lines (80 loc) · 2.58 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
def imageName = 'okaraev/matcher'
def appName = 'app_matcher'
def commit(){
sh(
script: 'git rev-parse HEAD',
returnStdout: true
).trim()
}
pipeline{
agent{
label 'docker'
}
stages{
stage('Checkout'){
steps{
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: true]],
submoduleCfg: [],
userRemoteConfigs: scm.userRemoteConfigs
])
}
}
stage('Pre-Integration Tests'){
steps{
script{
def testImage = docker.build("${imageName}-test:pipeline","-f ${appName}-test.df .")
parallel(
'Code Quality Test': {
sh "docker run --rm ${imageName}-test:pipeline golint"
},
'Dockerfile test' : {
sh "docker run --rm -i hadolint/hadolint:latest < ${appName}-test.df"
sh "docker run --rm -i hadolint/hadolint:latest < ${appName}.df"
}
)
}
}
}
stage('Unit Tests'){
steps{
script{
sh "docker run --rm ${imageName}-test:pipeline go test"
}
}
}
stage('Build'){
steps{
script{
docker.build(imageName,"-f ${appName}.df .")
}
}
}
stage('Push'){
steps{
script{
commit = commit()
docker.withRegistry('', 'registry') {
docker.image(imageName).push(commit)
docker.image(imageName).push("latest-${env.BRANCH_NAME}")
}
}
}
}
stage('Invoke CD'){
steps{
script{
if(env.BRANCH_NAME == 'master'){
timeout(time: 2, unit: "HOURS") {
input message: "Approve Deploy?", ok: "Yes"
}
build job: "Log2N/CD/${env.BRANCH_NAME}"
}
}
}
}
}
}