Add releasedockerhub command to cron 21/97721/14
authorBengt Thuree <bthuree@linuxfoundation.org>
Wed, 30 Oct 2019 06:12:26 +0000 (17:12 +1100)
committerBengt Thuree <bthuree@linuxfoundation.org>
Mon, 6 Jan 2020 08:31:26 +0000 (09:31 +0100)
Executing releasedockerhub command in lftools every week,
to ensure that not to many docker images needs to be copied every
time, as well as to keep cost down.

Signed-off-by: Bengt Thuree <bthuree@linuxfoundation.org>
Change-Id: I2ccdc236910960b3af3c1f6f1f0c5db062538c9c
Issue-ID: CIMAN-1

jjb/lf-infra-releasedockerhub.yaml [new file with mode: 0644]
shell/run_releasedockerhub.sh [new file with mode: 0644]

diff --git a/jjb/lf-infra-releasedockerhub.yaml b/jjb/lf-infra-releasedockerhub.yaml
new file mode 100644 (file)
index 0000000..ca2ea85
--- /dev/null
@@ -0,0 +1,68 @@
+---
+- builder:
+    name: lf-onap-releasedockerhub-macro
+    builders:
+      - shell: !include-raw-escape:
+        - ../shell/run_releasedockerhub.sh
+        ##- ../shell/run_releasedockerhub.sh "{org} {summary} {verbose} {copy}"
+
+
+- job:
+    name: lf-onap-release-docker-hub
+    build-timeout: 90
+
+    project-type: freestyle
+    node: ubuntu1604-docker-8c-8g                           ## Probably don't need this much
+    disable-job: false
+    disabled: '{disable-job}'
+
+    # Runs once a week 
+    triggers:
+      - timed: '@weekly'
+
+#   Define needed parameters for lf-infra-docker-login
+    parameters:
+      - string:
+          name: DOCKER_REGISTRY
+          default: 'nexus3.onap.org'
+      - string:
+          name: REGISTRY_PORTS
+          default: '10002'
+      - string:
+          name: DOCKERHUB_REGISTRY
+          default: 'docker.io'
+
+#   Define needed parameters for lf-onap-releasedockerhub-macro
+      - string:
+          name: RELEASEDOCKERHUB_ORG
+          default: 'onap'
+          description: ''
+      - string:
+          name: RELEASEDOCKERHUB_REPO
+          default: ''
+          description: 'Only match repos that contains this string'
+      - string:
+          name: RELEASEDOCKERHUB_EXACT
+          default: ''
+          description: 'Repo has to exactly match RELEASEDOCKERHUB_REPO '
+      - string:
+          name: RELEASEDOCKERHUB_SUMMARY
+          default: 'Yes'
+          description: 'Provides a brief statistic summary of what it found, and what it should do. Activate with Yes'
+      - string:
+          name: RELEASEDOCKERHUB_VERBOSE
+          default: ''
+          description: 'Provides a verbose output of the operations. Activate with Yes'
+      - string:
+          name: RELEASEDOCKERHUB_COPY
+          default: 'Yes'
+          description: 'If a copy operation should be done from Nexus3 to docker hub. Activate with Yes'
+
+
+    builders:
+      - lf-infra-pre-build                                  ## shell/python-tools-install.sh
+      - lf-infra-docker-login:
+          global-settings-file: 'global-settings'
+          settings-file: 'onap-releasedockerhub-authz-settings'
+      - lf-onap-releasedockerhub-macro:
+
diff --git a/shell/run_releasedockerhub.sh b/shell/run_releasedockerhub.sh
new file mode 100644 (file)
index 0000000..42771af
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2019 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+echo "---> run_releasedockerhub.sh"
+# Ensure we fail the job if any steps fail
+# Disable 'globbing'
+set -euf -o pipefail
+
+# shellcheck disable=SC1090
+source ~/lf-env.sh
+
+lf-activate-venv lftools
+
+if [ ! -v RELEASEDOCKERHUB_ORG ]
+then
+  echo "RELEASEDOCKERHUB_ORG is not defined. For onap set it to 'onap'"
+  exit 1
+fi
+
+cmd_str="--org $RELEASEDOCKERHUB_ORG"
+if [ -v RELEASEDOCKERHUB_SUMMARY ]
+then
+    cmd_str+=" --summary"
+fi
+if [ -v RELEASEDOCKERHUB_VERBOSE ]
+then
+    cmd_str+=" --verbose"
+fi
+if [ -v RELEASEDOCKERHUB_REPO ]
+then
+    cmd_str+=" --repo $RELEASEDOCKERHUB_REPO"
+fi
+if [ -v RELEASEDOCKERHUB_EXACT ]
+then
+    cmd_str+=" --exact"
+fi
+
+
+if [ -v RELEASEDOCKERHUB_COPY ]
+then
+    cmd_str+=" --copy"
+fi
+
+echo "cmd_str = >>$cmd_str<<"
+
+# Run the releasedockerhub command in lftools
+lftools nexus docker releasedockerhub  $cmd_str