Skip to content

Commit

Permalink
test: build docker image (#17905)
Browse files Browse the repository at this point in the history
* feat: push docker images

* fix: retrict a little the changes that trigger a full build

* fix: restore use of gitcheckout

* Update .ci/packaging.groovy
  • Loading branch information
kuisathaverat authored May 4, 2020
1 parent 3711ee6 commit 7d0a45a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
50 changes: 45 additions & 5 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,51 @@ pipeline {
}

def pushCIDockerImages(){
sh(label: 'Push Docker image', script: '''
if [ -n "$(command -v docker)" ]; then
docker images || true
fi
''')
catchError(buildResult: 'UNSTABLE', message: 'Unable to push Docker images', stageResult: 'FAILURE') {
if ("${env.BEATS_FOLDER}" == "auditbeat"){
tagAndPush('auditbeat-oss')
} else if ("${env.BEATS_FOLDER}" == "filebeat") {
tagAndPush('filebeat-oss')
} else if ("${env.BEATS_FOLDER}" == "heartbeat"){
tagAndPush('heartbeat')
tagAndPush('heartbeat-oss')
} else if ("${env.BEATS_FOLDER}" == "journalbeat"){
tagAndPush('journalbeat')
tagAndPush('journalbeat-oss')
} else if ("${env.BEATS_FOLDER}" == "metricbeat"){
tagAndPush('metricbeat-oss')
} else if ("${env.BEATS_FOLDER}" == "packetbeat"){
tagAndPush('packetbeat')
tagAndPush('packetbeat-oss')
} else if ("${env.BEATS_FOLDER}" == "x-pack/auditbeat"){
tagAndPush('auditbeat')
} else if ("${env.BEATS_FOLDER}" == "x-pack/elastic-agent") {
tagAndPush('elastic-agent')
} else if ("${env.BEATS_FOLDER}" == "x-pack/filebeat"){
tagAndPush('filebeat')
} else if ("${env.BEATS_FOLDER}" == "x-pack/metricbeat"){
tagAndPush('metricbeat')
}
}
}

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()
if("${env.SNAPSHOT}" == "true"){
libbetaVer += "-SNAPSHOT"
}
def oldName = "${DOCKER_REGISTRY}/beats/${name}:${libbetaVer}"
def newName = "${DOCKER_REGISTRY}/observability-ci/${name}:${libbetaVer}"
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}
""")
}
}

def release(){
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ def isChangedOSSCode(patterns) {
"^libbeat/.*",
"^testing/.*",
"^dev-tools/.*",
"^\\.ci/.*",
"^\\.ci/scripts/.*",
]
allPatterns.addAll(patterns)
return isChanged(allPatterns)
Expand All @@ -932,7 +932,7 @@ def isChangedXPackCode(patterns) {
"^dev-tools/.*",
"^testing/.*",
"^x-pack/libbeat/.*",
"^\\.ci/.*",
"^\\.ci/scripts/.*",
]
allPatterns.addAll(patterns)
return isChanged(allPatterns)
Expand Down

0 comments on commit 7d0a45a

Please sign in to comment.