@@ -125,11 +125,51 @@ pipeline {
125125}
126126
127127def pushCIDockerImages (){
128- sh(label : ' Push Docker image' , script : '''
129- if [ -n "$(command -v docker)" ]; then
130- docker images || true
131- fi
132- ''' )
128+ catchError(buildResult : ' UNSTABLE' , message : ' Unable to push Docker images' , stageResult : ' FAILURE' ) {
129+ if (" ${ env.BEATS_FOLDER} " == " auditbeat" ){
130+ tagAndPush(' auditbeat-oss' )
131+ } else if (" ${ env.BEATS_FOLDER} " == " filebeat" ) {
132+ tagAndPush(' filebeat-oss' )
133+ } else if (" ${ env.BEATS_FOLDER} " == " heartbeat" ){
134+ tagAndPush(' heartbeat' )
135+ tagAndPush(' heartbeat-oss' )
136+ } else if (" ${ env.BEATS_FOLDER} " == " journalbeat" ){
137+ tagAndPush(' journalbeat' )
138+ tagAndPush(' journalbeat-oss' )
139+ } else if (" ${ env.BEATS_FOLDER} " == " metricbeat" ){
140+ tagAndPush(' metricbeat-oss' )
141+ } else if (" ${ env.BEATS_FOLDER} " == " packetbeat" ){
142+ tagAndPush(' packetbeat' )
143+ tagAndPush(' packetbeat-oss' )
144+ } else if (" ${ env.BEATS_FOLDER} " == " x-pack/auditbeat" ){
145+ tagAndPush(' auditbeat' )
146+ } else if (" ${ env.BEATS_FOLDER} " == " x-pack/elastic-agent" ) {
147+ tagAndPush(' elastic-agent' )
148+ } else if (" ${ env.BEATS_FOLDER} " == " x-pack/filebeat" ){
149+ tagAndPush(' filebeat' )
150+ } else if (" ${ env.BEATS_FOLDER} " == " x-pack/metricbeat" ){
151+ tagAndPush(' metricbeat' )
152+ }
153+ }
154+ }
155+
156+ def tagAndPush (name ){
157+ 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()
158+ if (" ${ env.SNAPSHOT} " == " true" ){
159+ libbetaVer + = " -SNAPSHOT"
160+ }
161+ def oldName = " ${ DOCKER_REGISTRY} /beats/${ name} :${ libbetaVer} "
162+ def newName = " ${ DOCKER_REGISTRY} /observability-ci/${ name} :${ libbetaVer} "
163+ def commitName = " ${ DOCKER_REGISTRY} /observability-ci/${ name} :${ env.GIT_BASE_COMMIT} "
164+ dockerLogin(secret : " ${ DOCKERELASTIC_SECRET} " , registry : " ${ DOCKER_REGISTRY} " )
165+ retry(3 ){
166+ sh(label :' Change tag and push' , script : """
167+ docker tag ${ oldName} ${ newName}
168+ docker push ${ newName}
169+ docker tag ${ oldName} ${ commitName}
170+ docker push ${ commitName}
171+ """ )
172+ }
133173}
134174
135175def release (){
0 commit comments