Add docker push rules 97/6697/1
authorMike Marchetti <mmarchetti@sandvine.com>
Mon, 15 Oct 2018 13:40:57 +0000 (09:40 -0400)
committerMike Marchetti <mmarchetti@sandvine.com>
Mon, 15 Oct 2018 13:40:57 +0000 (09:40 -0400)
Change-Id: I819515f0d5879b0cedad0d70146bb3161bbebe3d
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
docker/mk/Makefile.include
docker/mk/dirs.mk
jenkins/ci-pipelines/ci_stage_3.groovy

index fb576e7..04d2fac 100644 (file)
@@ -56,4 +56,7 @@ clean:
        rm -f $(MKBUILD)/.dep*
 
 tag:
-       docker tag osm/$(CONTAINER_NAME) osm/$(LOWER_MDG):$(TAG)
+       docker tag osm/$(CONTAINER_NAME):$(INPUT_TAG) opensourcemano/$(LOWER_MDG):$(TAG)
+
+push: tag
+       docker push opensourcemano/$(LOWER_MDG):$(TAG)
index 53846cc..91100bb 100644 (file)
@@ -20,8 +20,9 @@ TOOLS_DIR := $(TOPDIR)/tools
 SUBDIRS_CLEAN = $(addsuffix .clean, $(SUBDIRS))
 SUBDIRS_TEST = $(addsuffix .test, $(SUBDIRS))
 SUBDIRS_TAG = $(addsuffix .tag, $(SUBDIRS))
+SUBDIRS_PUSH = $(addsuffix .push, $(SUBDIRS))
 
-.PHONY: $(SUBDIRS) $(SUBDIRS_CLEAN) clean test tag
+.PHONY: $(SUBDIRS) $(SUBDIRS_CLEAN) clean test tag push
 
 all: $(SUBDIRS)
 
@@ -40,6 +41,9 @@ $(SUBDIRS_TEST): %.test:
 $(SUBDIRS_TAG): %.tag:
        @$(MAKE) --no-print-directory -C $* tag 
 
+$(SUBDIRS_PUSH): %.push:
+       @$(MAKE) --no-print-directory -C $* push
+
 $(SUBDIRS):
        @$(MAKE) --no-print-directory -C $@
 
index ec4cdaf..1e9eb5a 100644 (file)
@@ -31,6 +31,7 @@ properties([
         string(defaultValue: 'dpkg1', description: '', name: 'GPG_KEY_NAME'),
         string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'),
         string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'),
+        string(defaultValue: 'releasefive-daily', description: '', name: 'DOCKER_TAG'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
         booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'),
@@ -38,6 +39,7 @@ properties([
         booleanParam(defaultValue: true, description: '',  name: 'DO_BUILD'),
         booleanParam(defaultValue: true, description: '', name: 'DO_INSTALL'),
         booleanParam(defaultValue: true, description: '', name: 'DO_SMOKE'),
+        booleanParam(defaultValue: true, description: '', name: 'DO_DOCKERPUSH'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_ARTIFACTS_OVERRIDE'),
     ])
 ])
@@ -75,8 +77,13 @@ node("${params.NODE}") {
     upstream_main_job += '-merge'
     container_name_prefix = "osm-${tag_or_branch}"
     container_name = "${container_name_prefix}"
+
+    keep_artifacts = false
     if ( JOB_NAME.contains('merge') ) {
         container_name += "-merge"
+
+        // On a merge job, we keep artifacts on smoke success
+        keep_artifacts = params.SAVE_ARTIFACTS_ON_SMOKE_SUCCESS
     }
     container_name += "-${BUILD_NUMBER}"
 
@@ -237,7 +244,7 @@ node("${params.NODE}") {
                     // archive smoke success until stage_4 is ready
 
                     if ( ! currentBuild.result.equals('UNSTABLE') ) {
-                        stage_archive = params.SAVE_ARTIFACTS_ON_SMOKE_SUCCESS
+                        stage_archive = keep_artifacts
                     }
                 }
             }
@@ -267,6 +274,11 @@ node("${params.NODE}") {
                     dir("${RELEASE_DIR}") {
                         ci_helper.archive(params.ARTIFACTORY_SERVER,RELEASE,GERRIT_BRANCH,'tested')
                     }
+                    if ( params.DO_DOCKERPUSH ) {
+                        stage("Docker Push") {
+                            sh "make -C docker push INPUT_TAG=${container_name} TAG=${params.DOCKER_TAG}"
+                        }
+                    }
                 }
             }
         }