-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile3
48 lines (44 loc) · 1.23 KB
/
Jenkinsfile3
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
#!/usr/bin/env groovy
@Library('shared-library@master') _ //master or whatever branch
def getDockerTag(){
def tag = sh script: 'git rev-parse HEAD', returnStdout: true
return tag
}
pipeline{
agent any
environment{
Docker_tag = getDockerTag()
}
parameters {
choice(name:'mvnaction',
choices: 'Clean\nCompile\nTest\nInstall',
description: 'based on selection jenkins will run resepective maven command')
}
stages{
stage('build'){
agent {
docker {
image 'maven'
args '-v $HOME/.m2:/root/.m2'
}
}
steps{
build ("${mvnaction}")
}
}
stage ('docker build and push') {
when {
expression { params.mvnaction == 'Install' }
}
steps {
sh 'cp -r ../shared-library@2/target .'
dockerbuild ("${Docker_tag}")
}
}
stage ('Check logs') {
steps {
filterLogs ('WARNING', 10)
}
}
}
}