Create common job template for post merge build jobs 99/6399/2
authorFatih Degirmenci <fatih.degirmenci@est.tech>
Tue, 27 Oct 2020 11:42:08 +0000 (11:42 +0000)
committerFatih Degirmenci <fatih.degirmenci@est.tech>
Tue, 27 Oct 2020 12:25:42 +0000 (12:25 +0000)
This change creates common job template, renames macros & scripts
and enables the use of the newly created job template for eiffel-playground
repo to test things out. Once it is verified working, the change will be
applied to other repos accordingly.

Change-Id: I0cbab579fafe9cc426aac56d9c82f5a3f15d0239

jjb/eiffel/eiffel-playground.yaml
jjb/eiffel/global-eiffel-container-build-merge.yaml [new file with mode: 0644]
jjb/eiffel/global-eiffel-container-build-periodic.yaml [moved from jjb/eiffel/global-eiffel-container-build.yaml with 100% similarity]
jjb/eiffel/macros/eiffel-macros.yaml
jjb/eiffel/scripts/eiffel-global-container-build.sh [new file with mode: 0644]

index 65959b84e74ea6df858f2ef8d77ef3bad3b8deb6..39f8578221df81df78ec7218c7fcf2724922ede4 100644 (file)
@@ -29,7 +29,7 @@
       - 'master':
           branch: 'master'
           project-git-repo: '{project}'
-          project-build-macro: 'eiffel-build-periodic-macro'
+          project-build-macro: 'eiffel-global-container-build-macro'
           image-dockerfile: 'Dockerfile'
           image-name: '{project}'
           image-tag: 'dev'
@@ -37,6 +37,6 @@
     distro: ubuntu2004
 
     jobs:
-      - '{project-name}-build-periodic-{distro}-{stream}'
+      - '{project-name}-build-merge-{distro}-{stream}'
 
 # vim: set ts=2 sw=2 expandtab:
diff --git a/jjb/eiffel/global-eiffel-container-build-merge.yaml b/jjb/eiffel/global-eiffel-container-build-merge.yaml
new file mode 100644 (file)
index 0000000..70596af
--- /dev/null
@@ -0,0 +1,113 @@
+---
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2020 Nordix Foundation.
+# ================================================================================
+# 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=========================================================
+
+- job-template:
+    name: '{project-name}-build-merge-{distro}-{stream}'
+
+    node: 'eiffel-build-{distro}'
+
+    disabled: false
+
+    concurrent: false
+
+    properties:
+      - logrotate
+      - github:
+          url: '$GIT_BASE_HTTPS/{project-git-repo}'
+
+    parameters:
+      - project-parameters:
+          project: '{project}'
+          branch: '{branch}'
+      - string:
+          name: GIT_BASE_HTTPS
+          default: https://github.com/eiffel-community
+          description: HTTPS URL of Project Repo on GitHub to clone repo.
+      - string:
+          name: GIT_BASE_SSH
+          default: git@github.com:eiffel-community
+          description: SSH URL of Project Repo on GitHub to clone repo.
+      - string:
+          name: IMAGE_DOCKERFILE
+          default: '{image-dockerfile}'
+          description: Dockerfile to use for building the container image
+      - string:
+          name: IMAGE_NAME
+          default: '{image-name}'
+          description: Name of the container image
+      - string:
+          name: IMAGE_TAG
+          default: '{image-tag}'
+          description: Tag to apply to the container image
+      - choice:
+          name: HARBOR_EIFFEL_PROJECT
+          choices:
+            - eiffel
+            - eiffel-playground
+          description: Project to push container images to. Default is eiffel. eiffel-playground is for development purposes.
+      - choice:
+          name: PODMAN_LOG_LEVEL
+          choices:
+            - error
+            - debug
+            - info
+            - warn
+            - fatal
+            - panic
+          description: Podman log level to use. Default is error.
+      - string:
+          name: NORDIX_REGISTRY
+          default: 'registry.nordix.org'
+          description: Nordix container image registry.
+
+    scm:
+      - git:
+          url: '$GIT_BASE_HTTPS/{project-git-repo}.git'
+          branches:
+            - '*/{branch}'
+          refspec: ''
+          timeout: 15
+          per-build-tag: false
+          skip-tag: true
+          shallow-clone: false
+          use-author: false
+          ignore-notify: false
+          wipe-workspace: true
+          prune: false
+          clean:
+            after: false
+            before: false
+          choosing-strategy: 'default'
+          basedir: '$WORKSPACE'
+
+    triggers:
+      - github
+
+    wrappers:
+      - build-timeout:
+          timeout: 10
+      - nordixinfra-harbor-creds-wrapper
+      - mask-passwords
+      - openstack:
+          single-use: True
+
+    builders:
+      - '{project-build-macro}'
+
+# vim: set ts=2 sw=2 expandtab:
index 699316e49e94ff868244f9e1e877827c700cb812..994d4b16be9b446ed1ce117a6367b9d49cc5c5f9 100644 (file)
@@ -1,4 +1,12 @@
 ---
+- builder:
+    name: 'eiffel-global-container-build-macro'
+    builders:
+      - shell:
+          !include-raw: ../scripts/eiffel-global-container-build.sh
+
+# NOTE (fdegir): below macros will potentially be removed or renamed
+# once the above macro is taken into use
 - builder:
     name: 'eiffel-build-periodic-macro'
     builders:
diff --git a/jjb/eiffel/scripts/eiffel-global-container-build.sh b/jjb/eiffel/scripts/eiffel-global-container-build.sh
new file mode 100644 (file)
index 0000000..7f9e6a3
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2020 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=========================================================
+
+set -o errexit
+set -o pipefail
+set -o nounset
+
+# navigate to root of the git clone
+cd "$WORKSPACE"
+
+# the Dockerfile to use for building the container image
+IMAGE_DOCKERFILE="${IMAGE_DOCKERFILE:?IMAGE_DOCKERFILE is unset!}"
+
+# the name of the container image
+IMAGE_NAME="${IMAGE_NAME:?IMAGE_NAME is unset!}"
+
+# the tag to apply to the container image
+IMAGE_TAG="${IMAGE_TAG:-latest}"
+
+# set image name
+IMAGE_NAME_TAG="$NORDIX_REGISTRY/$HARBOR_EIFFEL_PROJECT/$IMAGE_NAME:$IMAGE_TAG"
+
+# set the build command so we can log it to console
+PODMAN_BUILD_CMD="podman build --file $IMAGE_DOCKERFILE --log-level $PODMAN_LOG_LEVEL --tag $IMAGE_NAME_TAG ."
+
+echo "Info  : Building the container image with the command"
+echo "        $PODMAN_BUILD_CMD"
+echo "----------------------------------------------------------------"
+$PODMAN_BUILD_CMD
+echo "----------------------------------------------------------------"
+echo "Info  : Build successful! List of container images is"
+echo "----------------------------------------------------------------"
+podman images --log-level $PODMAN_LOG_LEVEL
+echo "----------------------------------------------------------------"
+echo "Info  : Logging in to registry.nordix.org and pushing the image"
+echo "----------------------------------------------------------------"
+podman login --log-level "$PODMAN_LOG_LEVEL" "$NORDIX_REGISTRY" --username "$HARBOR_USERNAME" --password "$HARBOR_PASSWORD"
+podman push --log-level "$PODMAN_LOG_LEVEL" "$IMAGE_NAME_TAG"
+podman logout --log-level "$PODMAN_LOG_LEVEL" "$NORDIX_REGISTRY"
+echo "----------------------------------------------------------------"
+echo "Info  : Done!"
+
+# vim: set ts=2 sw=2 expandtab: