From e817d462a097dafde0ab5f3dba1051363d664c3f Mon Sep 17 00:00:00 2001 From: Fatih Degirmenci Date: Tue, 23 Mar 2021 12:59:13 +0100 Subject: [PATCH] nsm: Create basic verify and periodic jobs This change creates basic verify and periodic jobs to start setting up the pipelines for NSM Meridio on Nordix Jenkins. Verify jobs consist of build and static analysis jobs. These jobs get triggered when a new PR is opened to Meridio repository and attempts to build and tag 6 container images and run static analysis. Result is sent to GitHub PR as checks. The jobs can be retriggered by commenting PR with /reverify in case if they fail for some infra issue. Periodic jobs consist of only build phase currently and they run on a nightly basis. These jobs build, tag, and push 6 container images. Please note that the images are tagged with latest tag and pushed to registry.nordix.org/cloud-native/meridio but the Git repo is not tagged. Change-Id: If9013152f20dbe1fe483c77dfceba57981a426fb --- jjb/nsm/nordix-nsm-meridio-periodic.yaml | 100 ++++++++++++++ jjb/nsm/nordix-nsm-meridio-verify.yaml | 169 +++++++++++++++++++++++ jjb/nsm/scripts/build.sh | 47 +++++++ jjb/nsm/scripts/static-analysis.sh | 36 +++++ 4 files changed, 352 insertions(+) create mode 100644 jjb/nsm/nordix-nsm-meridio-periodic.yaml create mode 100644 jjb/nsm/nordix-nsm-meridio-verify.yaml create mode 100755 jjb/nsm/scripts/build.sh create mode 100755 jjb/nsm/scripts/static-analysis.sh diff --git a/jjb/nsm/nordix-nsm-meridio-periodic.yaml b/jjb/nsm/nordix-nsm-meridio-periodic.yaml new file mode 100644 index 000000000..8ebe77672 --- /dev/null +++ b/jjb/nsm/nordix-nsm-meridio-periodic.yaml @@ -0,0 +1,100 @@ +--- +# ============LICENSE_START======================================================= +# Copyright (C) 2021 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========================================================= + +- project: + name: 'nsm-meridio-periodic' + + project: 'nsm-meridio-periodic' + + stream: + - 'master': + branch: 'master' + + image-name: + - ctraffic + - ipam + - load-balancer + - nsp + - proxy + - target + + jobs: + - 'nordix-nsm-meridio-{image-name}-periodic-build-{stream}' + +- job-template: + name: 'nordix-nsm-meridio-{image-name}-periodic-build-{stream}' + + disabled: '{obj:disabled}' + + concurrent: true + + node: nordix-nsm-build-ubuntu1804 + + properties: + - github: + url: https://github.com/nordix/meridio.git + + parameters: + - string: + name: GITHUB_ORGANIZATION + default: 'Nordix' + description: JJB configured parameter to identify GitHub Organization + - string: + name: PROJECT + default: 'meridio' + description: JJB configured PROJECT parameter to identify a Nordix GitHub project + - string: + name: IMAGE_NAME + default: '{image-name}' + description: Meridio image to verify build + - string: + name: IMAGE_VERSION + default: 'latest' + description: Meridio image version to build with + - string: + name: IMAGE_REGISTRY + default: 'registry.nordix.org/cloud-native/$PROJECT' + description: Meridio image version to build with + - string: + name: BUILD_STEPS + default: 'build tag push' + description: Steps to run during build + + scm: + - git: + url: 'https://github.com/$PROJECT.git' + branches: + - master + timeout: 15 + wipe-workspace: true + + triggers: + - timed: '@midnight' + + wrappers: + - build-timeout: + timeout: 10 + - nordixinfra-harbor-creds-wrapper + - mask-passwords + + builders: + - shell: + !include-raw: ./scripts/build.sh + +# vim: set ts=2 sw=2 expandtab: diff --git a/jjb/nsm/nordix-nsm-meridio-verify.yaml b/jjb/nsm/nordix-nsm-meridio-verify.yaml new file mode 100644 index 000000000..7ba1e8fa7 --- /dev/null +++ b/jjb/nsm/nordix-nsm-meridio-verify.yaml @@ -0,0 +1,169 @@ +--- +# ============LICENSE_START======================================================= +# Copyright (C) 2021 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========================================================= + +- project: + name: 'nsm-meridio-verify' + + project: 'nsm-meridio-verify' + + stream: + - 'master': + branch: '${{ghprbActualCommit}}' + + image-name: + - ctraffic + - ipam + - load-balancer + - nsp + - proxy + - target + + jobs: + - 'nordix-nsm-meridio-verify-static-analysis-{stream}' + - 'nordix-nsm-meridio-{image-name}-verify-build-{stream}' + +- job-template: + name: 'nordix-nsm-meridio-verify-static-analysis-{stream}' + + disabled: '{obj:disabled}' + + concurrent: true + + node: nordix-nsm-build-ubuntu1804 + + properties: + - github: + url: https://github.com/Nordix/Meridio.git + + parameters: + - string: + name: GITHUB_ORGANIZATION + default: 'Nordix' + description: JJB configured parameter to identify GitHub Organization + - string: + name: PROJECT + default: 'meridio' + description: JJB configured PROJECT parameter to identify a Nordix GitHub project + + scm: + - git: + url: 'https://github.com/$GITHUB_ORGANIZATION/$PROJECT.git' + branches: + - '{branch}' + refspec: '+refs/pull/*:refs/remotes/origin/pr/*' + timeout: 15 + wipe-workspace: true + choosing-strategy: 'default' + clean_before: false + + triggers: + - github-pull-request: + admin-list: + - nordixinfra + - uablrek + - LionelJouin + - fdegir + auth-id: 'nordix-nsm-github-token' + github-hooks: true + permit-all: true + trigger-phrase: '/reverify' + only-trigger-phrase: false + cron: 'H/5 * * * *' + status-context: 'Nordix Jenkins' + + builders: + - shell: + !include-raw: ./scripts/static-analysis.sh + +- job-template: + name: 'nordix-nsm-meridio-{image-name}-verify-build-{stream}' + + disabled: '{obj:disabled}' + + concurrent: true + + node: nordix-nsm-build-ubuntu1804 + + properties: + - github: + url: https://github.com/Nordix/Meridio.git + + parameters: + - string: + name: GITHUB_ORGANIZATION + default: 'Nordix' + description: JJB configured parameter to identify GitHub Organization + - string: + name: PROJECT + default: 'meridio' + description: JJB configured PROJECT parameter to identify a Nordix GitHub project + - string: + name: IMAGE_NAME + default: '{image-name}' + description: Meridio image to verify build + - string: + name: IMAGE_VERSION + default: 'dev' + description: Meridio image version to build with + - string: + name: IMAGE_REGISTRY + default: 'registry.nordix.org/cloud-native/$PROJECT' + description: Meridio image version to build with + - string: + name: BUILD_STEPS + default: 'build tag' + description: Steps to run during build + + scm: + - git: + url: 'https://github.com/$GITHUB_ORGANIZATION/$PROJECT.git' + branches: + - '{branch}' + refspec: '+refs/pull/*:refs/remotes/origin/pr/*' + timeout: 15 + wipe-workspace: true + choosing-strategy: 'default' + clean_before: false + + triggers: + - github-pull-request: + admin-list: + - nordixinfra + - uablrek + - LionelJouin + - fdegir + auth-id: 'nordix-nsm-github-token' + github-hooks: true + permit-all: true + trigger-phrase: '/reverify' + only-trigger-phrase: false + cron: 'H/5 * * * *' + status-context: 'Nordix Jenkins' + + wrappers: + - build-timeout: + timeout: 10 + - nordixinfra-harbor-creds-wrapper + - mask-passwords + + builders: + - shell: + !include-raw: ./scripts/build.sh + +# vim: set ts=2 sw=2 expandtab: diff --git a/jjb/nsm/scripts/build.sh b/jjb/nsm/scripts/build.sh new file mode 100755 index 000000000..7a57bfa06 --- /dev/null +++ b/jjb/nsm/scripts/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2021 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 WORKSPACE which is the root of the Git clone +cd $WORKSPACE + +# git show for information purposes +echo "--------------------------------------------" +git show +echo "--------------------------------------------" + +# login to image registry +echo "Info : Logging in to $IMAGE_REGISTRY" +echo "--------------------------------------------" +echo $HARBOR_PASSWORD | docker login --username $HARBOR_USERNAME --password-stdin $IMAGE_REGISTRY +echo "--------------------------------------------" + +# build the image +# the env vars are set by the job using parameters so update them instead +echo "Info : Starting the build using make $BUILD_STEPS" +echo "--------------------------------------------" +IMAGE=$IMAGE_NAME VERSION=$IMAGE_VERSION REGISTRY=$IMAGE_REGISTRY make $BUILD_STEPS +echo "--------------------------------------------" +echo "Info : Done!" + +# vim: set ts=2 sw=2 expandtab: diff --git a/jjb/nsm/scripts/static-analysis.sh b/jjb/nsm/scripts/static-analysis.sh new file mode 100755 index 000000000..779b9b4f5 --- /dev/null +++ b/jjb/nsm/scripts/static-analysis.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2021 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 WORKSPACE which is the root of the Git clone +cd $WORKSPACE + +# git show for information purposes +echo "--------------------------------------------" +git show +echo "--------------------------------------------" + +# command to run static analysis TBD +echo "Hello, World!" + +# vim: set ts=2 sw=2 expandtab: -- 2.25.1