eiffel: Create build macros and scripts for the projects 80/6180/9
authorFatih Degirmenci <fatih.degirmenci@est.tech>
Tue, 6 Oct 2020 13:59:42 +0000 (13:59 +0000)
committerFatih Degirmenci <fatih.degirmenci@est.tech>
Wed, 7 Oct 2020 09:51:45 +0000 (09:51 +0000)
Some Eiffel projects have different processes for builds which require
us to have project specific builder macros and scripts accordingly.

This change introduces such macros and scripts.

In order to ensure reusability, the projects with same build processes
use the same build macro which points to a common build script.

The job name is also updated according to convention.

Change-Id: Iaf00286214c2072a573401c45b12b6fd0835e3eb

13 files changed:
jjb/eiffel/eiffel-gerrit-herald.yaml
jjb/eiffel/eiffel-intelligence-frontend.yaml
jjb/eiffel/eiffel-intelligence.yaml
jjb/eiffel/eiffel-playground.yaml
jjb/eiffel/eiffel-remrem-generate.yaml
jjb/eiffel/eiffel-remrem-publish.yaml
jjb/eiffel/global-eiffel-container-build.yaml
jjb/eiffel/macros/eiffel-macros.yaml [new file with mode: 0644]
jjb/eiffel/scripts/eiffel-build-periodic.sh [moved from jjb/eiffel/scripts/eiffel-container-build-tag-push.sh with 96% similarity]
jjb/eiffel/scripts/eiffel-intelligence-build-periodic.sh [new file with mode: 0644]
jjb/eiffel/scripts/eiffel-intelligence-frontend-build-periodic.sh [new file with mode: 0644]
jjb/eiffel/scripts/eiffel-remrem-generate-build-periodic.sh [new file with mode: 0644]
jjb/eiffel/scripts/eiffel-remrem-publish-build-periodic.sh [new file with mode: 0644]

index 2a165df2b382c0e9eb9c58e1523e886073e4cc2e..33e2a67c5e6f42429a560f28adec4685f7b85092 100644 (file)
     stream:
       - 'master':
           branch: 'master'
-          project-build-root: './'
+          project-build-macro: 'eiffel-build-periodic-macro'
 
     distro: ubuntu2004
 
     jobs:
-      - '{project-name}-build-{distro}-{stream}-periodic'
+      - '{project-name}-build-periodic-{distro}-{stream}'
 
 # vim: set ts=2 sw=2 expandtab:
index 71c45177c6b89cc6062b83cedd8f43ca85c1cddc..6058d51a2651f8ff81b886f579b8eb36f19622d2 100644 (file)
     stream:
       - 'master':
           branch: 'master'
-          project-build-root: 'src/main/docker'
+          project-build-macro: 'eiffel-intelligence-frontend-build-periodic-macro'
 
     distro: ubuntu2004
 
     jobs:
-      - '{project-name}-build-{distro}-{stream}-periodic'
+      - '{project-name}-build-periodic-{distro}-{stream}'
 
 # vim: set ts=2 sw=2 expandtab:
index eb15f2d62bf3606f2768f51493f37cb237a32674..8d7d7e006e95ff4268f0d0168a5a5650db31ca7a 100644 (file)
     stream:
       - 'master':
           branch: 'master'
-          project-build-root: 'src/main/docker'
+          project-build-macro: 'eiffel-intelligence-build-periodic-macro'
 
     distro: ubuntu2004
 
     jobs:
-      - '{project-name}-build-{distro}-{stream}-periodic'
+      - '{project-name}-build-periodic-{distro}-{stream}'
 
 # vim: set ts=2 sw=2 expandtab:
index 2798afcb5fa8849eaff3f5f8624ce1b323cb85d2..501ace72e5f28c17ee381384e1fda7ad02d78131 100644 (file)
     stream:
       - 'master':
           branch: 'master'
-          project-build-root: './'
+          project-build-macro: 'eiffel-build-periodic-macro'
 
     distro: ubuntu2004
 
     jobs:
-      - '{project-name}-build-{distro}-{stream}-periodic'
+      - '{project-name}-build-periodic-{distro}-{stream}'
 
 # vim: set ts=2 sw=2 expandtab:
index bde59a06b3f3f2cdfa9ee60d895311b03bc9cbe2..c4189701df000f3040ca230ef26e87225b8d16a1 100644 (file)
     stream:
       - 'master':
           branch: 'master'
-          project-build-root: 'service/src/main/docker'
+          project-build-macro: 'eiffel-remrem-generate-build-periodic-macro'
 
     distro: ubuntu2004
 
     jobs:
-      - '{project-name}-build-{distro}-{stream}-periodic'
+      - '{project-name}-build-periodic-{distro}-{stream}'
 
 # vim: set ts=2 sw=2 expandtab:
index f80929227f72d2650204a4c14971da85934af8d8..7ac5b94f9988e5e42bc6446bd0eec56f07cc2fac 100644 (file)
     stream:
       - 'master':
           branch: 'master'
-          project-build-root: 'publish-service/src/main/docker'
+          project-build-macro: 'eiffel-remrem-publish-build-periodic-macro'
 
     distro: ubuntu2004
 
     jobs:
-      - '{project-name}-build-{distro}-{stream}-periodic'
+      - '{project-name}-build-periodic-{distro}-{stream}'
 
 # vim: set ts=2 sw=2 expandtab:
index cf2880096aeef09037b661bc56c185dd18801575..044a8e6e555065e17b1395bc0414ebe9682281de 100644 (file)
@@ -18,7 +18,7 @@
 # ============LICENSE_END=========================================================
 
 - job-template:
-    name: '{project-name}-build-{distro}-{stream}-periodic'
+    name: '{project-name}-build-periodic-{distro}-{stream}'
 
     node: 'eiffel-build-{distro}'
 
           name: GIT_BASE_SSH
           default: git@github.com:eiffel-community
           description: SSH URL of Project Repo on GitHub to clone repo.
-      - string:
-          name: PROJECT_BUILD_ROOT
-          default: '{project-build-root}'
-          description: Dockerfiles are located in different paths so this sets the path to navigate in the clone.
       - choice:
           name: HARBOR_EIFFEL_PROJECT
           choices:
           single-use: True
 
     builders:
-      - shell:
-          !include-raw-escape: ./scripts/eiffel-container-build-tag-push.sh
+      - '{project-build-macro}'
 
 # vim: set ts=2 sw=2 expandtab:
diff --git a/jjb/eiffel/macros/eiffel-macros.yaml b/jjb/eiffel/macros/eiffel-macros.yaml
new file mode 100644 (file)
index 0000000..699316e
--- /dev/null
@@ -0,0 +1,32 @@
+---
+- builder:
+    name: 'eiffel-build-periodic-macro'
+    builders:
+      - shell:
+          !include-raw: ../scripts/eiffel-build-periodic.sh
+
+- builder:
+    name: 'eiffel-intelligence-build-periodic-macro'
+    builders:
+      - shell:
+          !include-raw: ../scripts/eiffel-intelligence-build-periodic.sh
+
+- builder:
+    name: 'eiffel-intelligence-frontend-build-periodic-macro'
+    builders:
+      - shell:
+          !include-raw: ../scripts/eiffel-intelligence-frontend-build-periodic.sh
+
+- builder:
+    name: 'eiffel-remrem-generate-build-periodic-macro'
+    builders:
+      - shell:
+          !include-raw: ../scripts/eiffel-remrem-generate-build-periodic.sh
+
+- builder:
+    name: 'eiffel-remrem-publish-build-periodic-macro'
+    builders:
+      - shell:
+          !include-raw: ../scripts/eiffel-remrem-publish-build-periodic.sh
+
+# vim: set ts=2 sw=2 expandtab:
similarity index 96%
rename from jjb/eiffel/scripts/eiffel-container-build-tag-push.sh
rename to jjb/eiffel/scripts/eiffel-build-periodic.sh
index 26049e296300db2e1409c8c9e402ddc064ad8880..c989fa355544c570f9e12266d0d4e2b4eb03d740 100644 (file)
@@ -22,8 +22,8 @@ set -o errexit
 set -o pipefail
 set -o nounset
 
-# navigate to where Dockerfile is located
-cd "$WORKSPACE/$PROJECT_BUILD_ROOT"
+# navigate to root of the git clone
+cd "$WORKSPACE"
 
 # the image tagged with latest for the timebeing since we are building from the tip of master branch
 IMAGE_TAG="latest"
diff --git a/jjb/eiffel/scripts/eiffel-intelligence-build-periodic.sh b/jjb/eiffel/scripts/eiffel-intelligence-build-periodic.sh
new file mode 100644 (file)
index 0000000..6a68ea9
--- /dev/null
@@ -0,0 +1,80 @@
+#!/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"
+
+# TODO (fdegir): the versions need to be parameterized
+# they are hardcoded in the script to get the basic builds working
+# the job and script will be updated once the build is working and the versions are confirmed
+# set openjdk and maven versions
+OPENJDK_VERSION="8u265-b01-0ubuntu2~20.04"
+MAVEN_VERSION="3.6.3-1"
+
+# set maven build command
+MAVEN_BUILD_CMD="mvn --quiet --batch-mode package -DskipTests"
+
+# install openjdk and maven
+echo "Info  : Installing openjdk and maven"
+echo "----------------------------------------------------------------"
+sudo apt install -y -qq openjdk-8-jdk-headless="$OPENJDK_VERSION" maven="$MAVEN_VERSION"
+echo "----------------------------------------------------------------"
+echo "Info  : Building the project with the command"
+echo "        $MAVEN_BUILD_CMD"
+echo "----------------------------------------------------------------"
+$MAVEN_BUILD_CMD
+# find the warfile
+PROJECT_WAR_FILE=$(ls target/*.war)
+echo "----------------------------------------------------------------"
+echo "Info  : Build successful! Artifact is available as"
+ls -al $PROJECT_WAR_FILE
+echo "----------------------------------------------------------------"
+
+# the image tagged with latest for the timebeing since we are building from the tip of master branch
+IMAGE_TAG="latest"
+
+# set image name
+IMAGE_NAME_TAG="$NORDIX_REGISTRY/$HARBOR_EIFFEL_PROJECT/$PROJECT:$IMAGE_TAG"
+
+# set the build command so we can log it to console
+PODMAN_BUILD_CMD="podman build --build-arg URL=$PROJECT_WAR_FILE --file src/main/docker/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:
diff --git a/jjb/eiffel/scripts/eiffel-intelligence-frontend-build-periodic.sh b/jjb/eiffel/scripts/eiffel-intelligence-frontend-build-periodic.sh
new file mode 100644 (file)
index 0000000..6a68ea9
--- /dev/null
@@ -0,0 +1,80 @@
+#!/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"
+
+# TODO (fdegir): the versions need to be parameterized
+# they are hardcoded in the script to get the basic builds working
+# the job and script will be updated once the build is working and the versions are confirmed
+# set openjdk and maven versions
+OPENJDK_VERSION="8u265-b01-0ubuntu2~20.04"
+MAVEN_VERSION="3.6.3-1"
+
+# set maven build command
+MAVEN_BUILD_CMD="mvn --quiet --batch-mode package -DskipTests"
+
+# install openjdk and maven
+echo "Info  : Installing openjdk and maven"
+echo "----------------------------------------------------------------"
+sudo apt install -y -qq openjdk-8-jdk-headless="$OPENJDK_VERSION" maven="$MAVEN_VERSION"
+echo "----------------------------------------------------------------"
+echo "Info  : Building the project with the command"
+echo "        $MAVEN_BUILD_CMD"
+echo "----------------------------------------------------------------"
+$MAVEN_BUILD_CMD
+# find the warfile
+PROJECT_WAR_FILE=$(ls target/*.war)
+echo "----------------------------------------------------------------"
+echo "Info  : Build successful! Artifact is available as"
+ls -al $PROJECT_WAR_FILE
+echo "----------------------------------------------------------------"
+
+# the image tagged with latest for the timebeing since we are building from the tip of master branch
+IMAGE_TAG="latest"
+
+# set image name
+IMAGE_NAME_TAG="$NORDIX_REGISTRY/$HARBOR_EIFFEL_PROJECT/$PROJECT:$IMAGE_TAG"
+
+# set the build command so we can log it to console
+PODMAN_BUILD_CMD="podman build --build-arg URL=$PROJECT_WAR_FILE --file src/main/docker/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:
diff --git a/jjb/eiffel/scripts/eiffel-remrem-generate-build-periodic.sh b/jjb/eiffel/scripts/eiffel-remrem-generate-build-periodic.sh
new file mode 100644 (file)
index 0000000..b7cf3e2
--- /dev/null
@@ -0,0 +1,81 @@
+#!/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"
+
+# TODO (fdegir): the versions need to be parameterized
+# they are hardcoded in the script to get the basic builds working
+# the job and script will be updated once the build is working and the versions are confirmed
+# set openjdk and maven versions
+OPENJDK_VERSION="8u265-b01-0ubuntu2~20.04"
+MAVEN_VERSION="3.6.3-1"
+
+# set maven build command
+MAVEN_BUILD_CMD="mvn --quiet --batch-mode package -DskipTests"
+
+# install openjdk and maven
+echo "Info  : Installing openjdk and maven"
+echo "----------------------------------------------------------------"
+sudo apt install -y -qq openjdk-8-jdk-headless="$OPENJDK_VERSION" maven="$MAVEN_VERSION"
+echo "----------------------------------------------------------------"
+echo "Info  : Building the project with the command"
+echo "        $MAVEN_BUILD_CMD"
+echo "----------------------------------------------------------------"
+cd service
+$MAVEN_BUILD_CMD
+# find the warfile - we need to be in the folder where the service code is located
+PROJECT_WAR_FILE=$(ls target/*.war)
+echo "----------------------------------------------------------------"
+echo "Info  : Build successful! Artifact is available as"
+ls -al $PROJECT_WAR_FILE
+echo "----------------------------------------------------------------"
+
+# the image tagged with latest for the timebeing since we are building from the tip of master branch
+IMAGE_TAG="latest"
+
+# set image name
+IMAGE_NAME_TAG="$NORDIX_REGISTRY/$HARBOR_EIFFEL_PROJECT/$PROJECT:$IMAGE_TAG"
+
+# set the build command so we can log it to console
+PODMAN_BUILD_CMD="podman build --build-arg URL=$PROJECT_WAR_FILE --file src/main/docker/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:
diff --git a/jjb/eiffel/scripts/eiffel-remrem-publish-build-periodic.sh b/jjb/eiffel/scripts/eiffel-remrem-publish-build-periodic.sh
new file mode 100644 (file)
index 0000000..c79d254
--- /dev/null
@@ -0,0 +1,81 @@
+#!/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"
+
+# TODO (fdegir): the versions need to be parameterized
+# they are hardcoded in the script to get the basic builds working
+# the job and script will be updated once the build is working and the versions are confirmed
+# set openjdk and maven versions
+OPENJDK_VERSION="8u265-b01-0ubuntu2~20.04"
+MAVEN_VERSION="3.6.3-1"
+
+# set maven build command
+MAVEN_BUILD_CMD="mvn --quiet --batch-mode package -DskipTests"
+
+# install openjdk and maven
+echo "Info  : Installing openjdk and maven"
+echo "----------------------------------------------------------------"
+sudo apt install -y -qq openjdk-8-jdk-headless="$OPENJDK_VERSION" maven="$MAVEN_VERSION"
+echo "----------------------------------------------------------------"
+echo "Info  : Building the project with the command"
+echo "        $MAVEN_BUILD_CMD"
+echo "----------------------------------------------------------------"
+$MAVEN_BUILD_CMD
+# find the warfile - we need to be in the folder where the service code is located
+cd publish-service
+PROJECT_WAR_FILE=$(ls target/*.war)
+echo "----------------------------------------------------------------"
+echo "Info  : Build successful! Artifact is available as"
+ls -al $PROJECT_WAR_FILE
+echo "----------------------------------------------------------------"
+
+# the image tagged with latest for the timebeing since we are building from the tip of master branch
+IMAGE_TAG="latest"
+
+# set image name
+IMAGE_NAME_TAG="$NORDIX_REGISTRY/$HARBOR_EIFFEL_PROJECT/$PROJECT:$IMAGE_TAG"
+
+# set the build command so we can log it to console
+PODMAN_BUILD_CMD="podman build --build-arg URL=$PROJECT_WAR_FILE --file src/main/docker/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: