This repository was archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJenkinsfile
More file actions
62 lines (53 loc) · 1.64 KB
/
Jenkinsfile
File metadata and controls
62 lines (53 loc) · 1.64 KB
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
node {
properties([
[$class: 'BuildDiscarderProperty',
strategy: [
$class: 'LogRotator',
artifactNumToKeepStr: '5',
daysToKeepStr: '30']
],
disableConcurrentBuilds(),
rateLimitBuilds([count: 1, durationName: 'minute', userBoost: false]),
pipelineTriggers([upstream(upstreamProjects: 'hop', threshold: hudson.model.Result.SUCCESS)]),
parameters([
string(name: 'PRM_BRANCHNAME', defaultValue: "master"),
string(name: 'PRM_BUILD_NUMBER', defaultValue: "0"),
]),
])
try{
stage('Checkout') {
checkout scm
}
stage('Upstream Variables') {
echo "upstream Branch: ${params.PRM_BRANCHNAME}"
echo "upstream Build Number: ${params.PRM_BUILD_NUMBER}"
}
stage('Build image') {
docker.withRegistry('', 'dockerhub') {
if("${params.PRM_BRANCHNAME}" == "master"){
// Create container with snapshot tag
def customImage = docker.build("projecthop/hop:snapshot" , "--build-arg BRANCH_NAME=${params.PRM_BRANCHNAME} .")
customImage.push()
} else
{
// create container with release tag
def customImage = docker.build("projecthop/hop:${params.PRM_BRANCHNAME}", "--build-arg BRANCH_NAME=${params.PRM_BRANCHNAME} .")
customImage.push()
}
/* Push the container to the custom Registry */
}
}
stage('Cleanup'){
if("${params.PRM_BRANCHNAME}" == "master"){
sh 'docker rmi projecthop/hop:snapshot'
}
else
{
sh "docker rmi projecthop/hop:${params.PRM_BRANCHNAME}"
}
}
} finally
{
cleanWs()
}
}