Skip to content

Commit

Permalink
feat: push aliases for docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Oct 19, 2020
1 parent 78856ca commit 3cd405d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,12 @@ def pushCIDockerImages(){

def tagAndPush(name){
def libbetaVer = sh(label: 'Get libbeat version', script: 'grep defaultBeatVersion ${BASE_DIR}/libbeat/version/version.go|cut -d "=" -f 2|tr -d \\"', returnStdout: true)?.trim()
def aliasVersion = ""
if("${env.SNAPSHOT}" == "true"){
aliasVersion = libbetaVer.substring(0, libbetaVer.lastIndexOf(".")) // remove third number in version

libbetaVer += "-SNAPSHOT"
aliasVersion += "-SNAPSHOT"
}

def tagName = "${libbetaVer}"
Expand Down Expand Up @@ -227,6 +231,24 @@ def tagAndPush(name){
log(level: 'WARN', text: "${name} doesn't have ${variant} docker images. See https://github.com/elastic/beats/pull/21621")
}
}

if (aliasVersion != "") {
def aliasName = "${DOCKER_REGISTRY}/observability-ci/${name}${variant}:${aliasVersion}"
def iterations = 0
retryWithSleep(retries: 3, seconds: 5, backoff: true) {
iterations++
def status = sh(label:'Change tag and push', script: """
docker tag ${oldName} ${aliasName}
docker push ${newName}
""", 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 3cd405d

Please sign in to comment.