This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
74 lines (65 loc) · 2.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@Library('github.com/fabric8io/fabric8-pipeline-library@master')
def utils = new io.fabric8.Utils()
def flow = new io.fabric8.Fabric8Commands()
def project = 'fabric8-ui/fabric8-ui-openshift-nginx'
def tempVersion
def imageName = 'fabric8/fabric8-openshift-nginx'
clientsTemplate{
dockerNode{
if (utils.isCI()){
checkout scm
container(name: 'docker') {
tempVersion = "SNAPSHOT-${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
stage ('build snapshot image'){
sh "docker build -t ${imageName}:${tempVersion} ."
}
stage ('push snapshot image'){
sh "docker push ${imageName}:${tempVersion}"
}
}
stage('notify'){
def changeAuthor = env.CHANGE_AUTHOR
if (!changeAuthor){
error "no commit author found so cannot comment on PR"
}
def pr = env.CHANGE_ID
if (!pr){
error "no pull request number found so cannot comment on PR"
}
def message = "@${changeAuthor} snapshot fabric8-ui-openshift-nginx image is available for testing. `docker pull ${imageName}:${tempVersion}`"
container('docker'){
flow.addCommentToPullRequest(message, pr, "fabric8-ui/fabric8-ui-openshift-nginx")
}
}
} else if (utils.isCD()){
git "https://github.com/${project}.git"
sh "git remote set-url origin [email protected]:${project}.git"
def version
version = getNewVersion {}
container(name: 'docker') {
stage ('build snapshot image'){
sh "docker build -t ${imageName}:${version} ."
}
stage ('push snapshot image'){
sh "docker push ${imageName}:${version}"
sh "docker tag ${imageName}:${version} ${imageName}:latest"
sh "docker push ${imageName}:latest"
}
}
updateDownstreamRepoDependencies(version)
}
}
}
def updateDownstreamRepoDependencies(v) {
pushNewDockerImageTagChangePR {
propertyName = 'fabric8\\/fabric8-openshift-nginx'
parentDockerfileLocation = 'Dockerfile.deploy'
projects = [
'fabric8-ui/fabric8-ui',
'openshiftio/openshift.io'
]
version = v
autoMerge = false
containerName = 'clients'
}
}