engine: Generate SDF for change 84/4484/3
authorFatih Degirmenci <fdegir@gmail.com>
Sun, 19 Apr 2020 17:58:00 +0000 (17:58 +0000)
committerFatih Degirmenci <fdegir@gmail.com>
Sun, 19 Apr 2020 18:32:59 +0000 (18:32 +0000)
Change-Id: I70e2747eccc0202d9502e61e7a3039b5efbd7c91

jjb/engine/engine-macros.yaml
jjb/engine/scripts/generate-sdf-for-change.sh [new file with mode: 0755]
jjb/engine/verify-jobs/engine-verify-deploy-test.yaml
jjb/engine/verify-jobs/engine-verify-package.yaml
jjb/engine/verify-jobs/engine-verify-tox.yaml

index aa893b5b33f60f7abbef8c150d33dbd4e9a4da1d..6dbbb20d5b6af1e57c6aaec7552128de972f88c6 100644 (file)
           !include-raw: ./scripts/tox.sh
 
 
+- builder:
+    name: 'generate-sdf-for-change-macro'
+    builders:
+      - shell:
+          !include-raw: ./scripts/generate-sdf-for-change.sh
+
 - builder:
     name: 'generate-ssh-keypair-macro'
     builders:
diff --git a/jjb/engine/scripts/generate-sdf-for-change.sh b/jjb/engine/scripts/generate-sdf-for-change.sh
new file mode 100755 (executable)
index 0000000..cf88808
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+# NOTE (fdegir): we do not need to do anything for the changes coming to infra/engine repo
+if [[ "$GERRIT_PROJECT" == "infra/engine" ]]; then
+  exit 0
+fi
+
+echo "Info : Cloning infra/engine repository"
+cd "$HOME" && /bin/rm -rf "$WORKSPACE"
+git clone -q "$ENGINE_REPO_URL" "$WORKSPACE"
+
+export SDF_ORIGINAL="$WORKSPACE/engine/inventory/group_vars/all/sdf.yaml"
+export SDF_PATCHSET="/tmp/sdf.yaml.$GERRIT_CHANGE_NUMBER"
+
+/bin/rm -rf "$SDF_PATCHSET"
+
+export TOOL_TYPE="${GERRIT_PROJECT//*\//}"
+export TOOL_MATCH="false"
+echo "Info  : Tool type is $TOOL_TYPE"
+echo "Info  : Updating SDF with change SHA and refspec"
+while IFS= read -r line; do
+  if [[ "$TOOL_MATCH" == "true" && "$line" =~ "version" ]]; then
+    echo "$line" | sed "s#version:.*#version: $GERRIT_PATCHSET_REVISION\n    refspec: $GERRIT_REFSPEC#g" >> "$SDF_PATCHSET"
+    export TOOL_MATCH="false"
+    continue
+  fi
+  if [[ "$line" =~ "$TOOL_TYPE:" && "$TOOL_MATCH" == "false" ]]; then
+    export TOOL_MATCH="true"
+  fi
+  echo "$line" >> "$SDF_PATCHSET"
+done < "$SDF_ORIGINAL"
+# NOTE (fdegir): log the diff for possible troubleshooting
+echo
+echo "Info  : Diff between original SDF and SDF generated for the change"
+echo "-------------------------------------------------------------------------"
+diff "$SDF_ORIGINAL" "$SDF_PATCHSET"
+echo "-------------------------------------------------------------------------"
+echo
+
+# NOTE (fdegir): move SDF generated for the change into the original SDF
+/bin/mv -f "$SDF_PATCHSET" "$SDF_ORIGINAL"
+
+# NOTE (fdegir): log the final SDF
+echo
+echo "Info  : Generated SDF content"
+echo "-------------------------------------------------------------------------"
+cat "$SDF_ORIGINAL"
+echo "-------------------------------------------------------------------------"
+echo
index e24377b592785d371eb7204124f21d497c4909bf..54a7fa870a1a42386901e7dc41c81c0596022875 100644 (file)
       - virtual:
           provisioner-type: 'bifrost'
           slave-type: 'vpod'
-          gated-projects: 'infra\/engine|infra\/provisioner\/bifrost\/|infra\/installer\/kolla\/|infra\/installer\/kubespray\/'
+          gated-projects: 'infra/engine|infra/provisioner/bifrost|infra/installer/kolla|infra/installer/kubespray'
       - cloud:
           provisioner-type: 'heat'
           slave-type: 'jumphost'
-          gated-projects: 'infra\/engine|infra\/provisioner\/heat\/|infra\/installer\/kolla\/|infra\/installer\/kubespray\/'
+          gated-projects: 'infra/engine|infra/provisioner/heat|infra/installer/kubespray'
 
     distro:
       - ubuntu1804
           name: SLAVE_LABEL
           default: 'engine-{slave-type}-{environment-type}-{distro}'
           description: 'Slave label to schedule this job on.'
+      - string:
+          name: ENGINE_REPO_URL
+          default: 'https://gerrit.nordix.org/infra/engine.git'
+          description: 'URL to Nordix Cloud Infra engine repository'
       - string:
           name: EXECUTION_MODE
           default: '{execution-mode}'
     scm:
       - git-scm-gerrit:
           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
-          branch: '{branch}'
+          branch: refs/heads/$GERRIT_BRANCH
           refspec: $GERRIT_REFSPEC
           wipe_workspace: true
           clean_before: false
     scm:
       - git-scm-gerrit:
           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
-          branch: '{branch}'
+          branch: refs/heads/$GERRIT_BRANCH
           refspec: $GERRIT_REFSPEC
           wipe_workspace: true
           clean_before: false
             echo "Info  : Offline deployment and testing on cloud instances is not currently supported!"
             exit 0
           fi
+      - 'generate-sdf-for-change-macro'
       - 'generate-ssh-keypair-macro'
       - 'wait-pkg-mgr-macro'
       - 'download-artifact-macro'
index 27f4b2e9dedfb8e0d1f4141cf2a74d2784a19e75..8a7f1cdc3fe7a1a1771eb1d855a8fd01eca7290d 100644 (file)
@@ -27,7 +27,7 @@
           branch: '{stream}'
           openrc-credentials-file: 'est-jenkins-openrcfile-city-karlskrona-onap'
           execution-mode: 'packaging'
-          gated-projects: 'infra\/engine'
+          gated-projects: 'infra/engine|infra/provisioner/bifrost|infra/provisioner/heat|infra/installer/kolla|infra/installer/kubespray'
           successful: false
           failed: false
           unstable: false
           name: VERBOSITY
           default: 'true'
           description: 'Verbosity setting for the engine - true or false - default is false'
+      - string:
+          name: ENGINE_REPO_URL
+          default: 'https://gerrit.nordix.org/infra/engine.git'
+          description: 'URL to Nordix Cloud Infra engine repository'
       - string:
           name: ARTIFACTS_TO_UPLOAD
           default: "k8s-installer-ubuntu1804.bsx"
     scm:
       - git-scm-gerrit:
           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
-          branch: '{branch}'
+          branch: refs/heads/$GERRIT_BRANCH
           refspec: $GERRIT_REFSPEC
           wipe_workspace: true
           clean_before: false
 
 
     builders:
+      - 'generate-sdf-for-change-macro'
       - 'generate-ssh-keypair-macro'
       - 'wait-pkg-mgr-macro'
       - 'package-macro'
index 4561c13ec41f082a7c483e83c7529021cef28759..3d34add817df4118d8e1729744d42387ac9cad02 100644 (file)
@@ -25,6 +25,7 @@
     stream:
       - 'master':
           branch: '{stream}'
+          gated-projects: 'infra/engine|infra/hwconfig|infra/swconfig|infra/test|infra/provisioner/bifrost|infra/provisioner/heat|infra/installer/kolla|infra/installer/kubespray'
 
     lint-type:
       - ansible-lint:
@@ -32,7 +33,7 @@
           repos-to-ignore: 'infra/hwconfig'
       - docs:
           disabled: false
-          repos-to-ignore: 'infra/hwconfig|infra/swconfig|infra/test'
+          repos-to-ignore: 'infra/hwconfig|infra/swconfig|infra/test|infra/provisioner/bifrost|infra/provisioner/heat|infra/installer/kolla|infra/installer/kubespray'
       - shellcheck:
           disabled: false
           repos-to-ignore: 'infra/hwconfig'
@@ -75,7 +76,7 @@
     scm:
       - git-scm-gerrit:
           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
-          branch: '{branch}'
+          branch: refs/heads/$GERRIT_BRANCH
           refspec: $GERRIT_REFSPEC
           wipe_workspace: true
           clean_before: false
@@ -95,7 +96,7 @@
                 comment-contains-value: 'reverify'
           projects:
             - project-compare-type: 'REG_EXP'
-              project-pattern: 'infra\/engine|infra\/test|infra\/swconfig|infra\/hwconfig'
+              project-pattern: '{gated-projects}'
               branches:
                 - branch-compare-type: 'ANT'
                   branch-pattern: '**/{branch}'
     scm:
       - git-scm-gerrit:
           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
-          branch: '{branch}'
+          branch: refs/heads/$GERRIT_BRANCH
           refspec: $GERRIT_REFSPEC
           wipe_workspace: true
           clean_before: false