Skip to content

Commit

Permalink
[CI: Packaging] fix: push ubi8 images too (elastic#21621)
Browse files Browse the repository at this point in the history
* fix: push ubi8 images too

* chore: enhance retries

Co-authored-by: Victor Martinez <[email protected]>

* chore: use variables in log

* chore: add "-oss" images

Co-authored-by: Victor Martinez <[email protected]>
  • Loading branch information
2 people authored and jsoriano committed Dec 14, 2020
1 parent bb7e486 commit 9be1263
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,30 @@ def tagAndPush(name){
tagName = "pr-${env.CHANGE_ID}"
}

def oldName = "${DOCKER_REGISTRY}/beats/${name}:${libbetaVer}"
def newName = "${DOCKER_REGISTRY}/observability-ci/${name}:${tagName}"
def commitName = "${DOCKER_REGISTRY}/observability-ci/${name}:${env.GIT_BASE_COMMIT}"
dockerLogin(secret: "${DOCKERELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}")
retry(3){
sh(label:'Change tag and push', script: """
docker tag ${oldName} ${newName}
docker push ${newName}
docker tag ${oldName} ${commitName}
docker push ${commitName}
""")

// supported image flavours
def variants = ["", "-oss", "-ubi8"]
variants.each { variant ->
def oldName = "${DOCKER_REGISTRY}/beats/${name}${variant}:${libbetaVer}"
def newName = "${DOCKER_REGISTRY}/observability-ci/${name}${variant}:${tagName}"
def commitName = "${DOCKER_REGISTRY}/observability-ci/${name}${variant}:${env.GIT_BASE_COMMIT}"

def iterations = 0
retryWithSleep(retries: 3, seconds: 5, backoff: true)
iterations++
def status = sh(label:'Change tag and push', script: """
docker tag ${oldName} ${newName}
docker push ${newName}
docker tag ${oldName} ${commitName}
docker push ${commitName}
""", returnStatus: true)
if ( status > 0 && iterations < 3) {
error('tag and push failed, retry')
} else if ( status > 0 ) {
log(level: 'WARN', text: "${name} doesn't have ${variant} docker images. See https://github.com/elastic/beats/pull/21621")
}
}
}
}

Expand Down

0 comments on commit 9be1263

Please sign in to comment.