/
getDockerDigest.groovy
36 lines (32 loc) · 1.18 KB
/
getDockerDigest.groovy
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
#!groovy
def call(String secret, Closure body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
stage('Retrieve Docker Digest') {
openshift.withCluster( config.openShiftUri, secret ) {
openshift.withProject( config.openShiftProject ) {
def istagobj = openshift.selector( "istag/${config.imageName}:${config.imageTag}" ).object()
return istagobj.image.metadata.name
}
}
}
}
def call(Closure body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'container-zone',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
stage('Retrieve Docker Digest') {
openshift.withCluster( config.openShiftUri, env.PASSWORD ) {
openshift.withProject( env.USERNAME ) {
def istagobj = openshift.selector( "istag/${config.imageName}:${config.imageTag}" ).object()
return istagobj.image.metadata.name
}
}
}
}
}