-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
50 lines (48 loc) · 1.33 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
properties([
parameters([
gitParameter(
branch: '',
branchFilter: 'origin/(.*)',
defaultValue: 'master',
description: '',
name: 'BRANCH',
quickFilterEnabled: false,
selectedValue: 'NONE',
sortMode: 'NONE',
tagFilter: '*',
useRepository: '[email protected]:aronwk-aaron/atu-ilt.git',
type: 'PT_BRANCH'
)
])
])
node('worker'){
stage('Clone Code'){
checkout([
$class: 'GitSCM',
branches: [[name: params.BRANCH]],
extensions: [],
userRemoteConfigs: [
[
credentialsId: 'aronwk',
url: '[email protected]:aronwk-aaron/atu-ilt.git'
]
]
])
}
def tag = ''
stage("Build Container"){
if (params.BRANCH.contains('master')){
tag = 'latest'
} else {
tag = params.BRANCH.replace('\\', '-')
}
sh "docker build -t aronwk/ilt:${tag} ."
}
stage("Push Container"){
withCredentials([usernamePassword(credentialsId: 'docker-hub-token', passwordVariable: 'password', usernameVariable: 'username')]) {
sh "docker login -u ${username} -p ${password}"
sh "docker push aronwk/ilt:${tag}"
sh 'docker logout'
}
}
}