From 7ef7632b7b38484f7dd17713760030e9d36bbcef Mon Sep 17 00:00:00 2001 From: Josep Puigdemont Date: Fri, 6 May 2016 06:22:06 +0200 Subject: [PATCH] armband: add ci jobs Change-Id: I6918dc1189ab18fa79812ffa7c5e67867a945eba Signed-off-by: Josep Puigdemont --- jjb/armband/armband-ci-jobs.yml | 193 +++++++++++++++++++++++++++++++ jjb/armband/armband-deploy.sh | 79 +++++++++++++ jjb/armband/armband-download-artifact.sh | 66 +++++++++++ jjb/opnfv/slave-params.yml | 12 ++ 4 files changed, 350 insertions(+) create mode 100644 jjb/armband/armband-ci-jobs.yml create mode 100755 jjb/armband/armband-deploy.sh create mode 100755 jjb/armband/armband-download-artifact.sh diff --git a/jjb/armband/armband-ci-jobs.yml b/jjb/armband/armband-ci-jobs.yml new file mode 100644 index 000000000..3877d4481 --- /dev/null +++ b/jjb/armband/armband-ci-jobs.yml @@ -0,0 +1,193 @@ +# jenkins job templates for Armband +- project: + name: 'armband-ci' + project: '{name}' + installer: 'fuel' + +#-------------------------------- +# BRANCH ANCHORS +#-------------------------------- + master: &master + stream: master + branch: '{stream}' + gs-pathname: '' + brahmaputra: &brahmaputra + stream: brahmaputra + branch: 'stable/{stream}' + gs-pathname: '/{stream}' +#-------------------------------- +# POD, INSTALLER, AND BRANCH MAPPING +#-------------------------------- +# brahmaputra +#-------------------------------- + pod: + - arm-pod1: + <<: *brahmaputra +#-------------------------------- +# master +#-------------------------------- +# No master deploys for now +# - arm-pod1: +# <<: *master +#-------------------------------- +# scenarios +#-------------------------------- + scenario: + # HA scenarios + - 'os-odl_l2-nofeature-ha': + auto-trigger-name: 'brahmaputra-trigger-daily-disabled' + + # NOHA scenarios + - 'os-odl_l2-nofeature-noha': + auto-trigger-name: 'brahmaputra-trigger-daily-disabled' + + jobs: + - 'armband-{scenario}-{pod}-daily-{stream}' + - 'armband-deploy-{pod}-daily-{stream}' + +######################## +# job templates +######################## +- job-template: + name: 'armband-{scenario}-{pod}-daily-{stream}' + + concurrent: false + + properties: + - throttle: + enabled: true + max-total: 1 + max-per-node: 1 + - build-blocker: + use-build-blocker: true + blocking-jobs: + - 'armband-os-.*?-{pod}-daily-{stream}' + block-level: 'NODE' + + wrappers: + - build-name: + name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO' + + triggers: + - '{auto-trigger-name}' + + parameters: + - project-parameter: + project: '{project}' + - '{installer}-defaults' + - '{pod}-defaults': + installer: '{installer}' + - string: + name: DEPLOY_SCENARIO + default: '{scenario}' + - armband-ci-parameter: + gs-pathname: '{gs-pathname}' + + builders: + - trigger-builds: + - project: 'armband-deploy-{pod}-daily-{stream}' + current-parameters: false + predefined-parameters: + DEPLOY_SCENARIO={scenario} + same-node: true + block: true + - trigger-builds: + - project: 'functest-armband-{pod}-daily-{stream}' + current-parameters: false + predefined-parameters: + DEPLOY_SCENARIO={scenario} + block: true + same-node: true + block-thresholds: + build-step-failure-threshold: 'never' + failure-threshold: 'never' + unstable-threshold: 'FAILURE' + +- job-template: + name: 'armband-deploy-{pod}-daily-{stream}' + + concurrent: false + + properties: + - throttle: + enabled: true + max-total: 1 + max-per-node: 1 + - build-blocker: + use-build-blocker: true + blocking-jobs: + - 'armband-deploy-{pod}-daily-{stream}' + - 'armband-deploy-generic-daily-.*' + block-level: 'NODE' + + parameters: + - project-parameter: + project: '{project}' + - '{installer}-defaults' + - '{pod}-defaults': + installer: '{installer}' + - string: + name: DEPLOY_SCENARIO + default: 'os-odl_l2-nofeature-ha' + - armband-ci-parameter: + gs-pathname: '{gs-pathname}' + + scm: + - git-scm: + credentials-id: '{ssh-credentials}' + refspec: '' + branch: '{branch}' + + wrappers: + - build-name: + name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO' + + builders: + - shell: + !include-raw-escape: ./armband-download-artifact.sh + - shell: + !include-raw-escape: ./armband-deploy.sh + + publishers: + - email: + recipients: josep.puigdemont@enea.com armband@enea.com + +######################## +# parameter macros +######################## +- parameter: + name: armband-ci-parameter + parameters: + - string: + name: BUILD_DIRECTORY + default: $WORKSPACE/build_output + description: "Directory where the build artifact will be located upon the completion of the build." + - string: + name: CACHE_DIRECTORY + default: $HOME/opnfv/cache/$INSTALLER_TYPE + description: "Directory where the cache to be used during the build is located." + - string: + name: GS_URL + default: artifacts.opnfv.org/$PROJECT{gs-pathname} + description: "URL to Google Storage." + +######################## +# trigger macros +######################## +# CI PODs +#---------------------------------------------------------- +# Enea Armband POD 1 Triggers running against master branch +#---------------------------------------------------------- +# No triggers for master for now +- trigger: + name: 'armband-os-odl_l2-nofeature-ha-arm-pod1-master-trigger' + triggers: + - timed: '' + +#--------------------------------------------------------------- +# Enea Armband POD 1 Triggers running against brahmaputra branch +#--------------------------------------------------------------- +- trigger: + name: 'armband-os-odl_l2-nofeature-ha-arm-pod1-brahmaputra-trigger' + triggers: + - timed: '0 6 * * *' diff --git a/jjb/armband/armband-deploy.sh b/jjb/armband/armband-deploy.sh new file mode 100755 index 000000000..222a388e6 --- /dev/null +++ b/jjb/armband/armband-deploy.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2016 Ericsson AB and others. +# (c) 2016 Enea Software AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -o errexit +set -o nounset +set -o pipefail + +# source the file so we get OPNFV vars +source latest.properties + +# echo the info about artifact that is used during the deployment +echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment" + +if [[ "$JOB_NAME" =~ "merge" ]]; then + # set simplest scenario for virtual deploys to run for merges + DEPLOY_SCENARIO="os-nosdn-nofeature-ha" +else + # for none-merge deployments + # checkout the commit that was used for building the downloaded artifact + # to make sure the ISO and deployment mechanism uses same versions + echo "Checking out $OPNFV_GIT_SHA1" + git checkout $OPNFV_GIT_SHA1 --quiet +fi + +# set deployment parameters +export TMPDIR=$HOME/tmpdir +BRIDGE=${DEFAULT_BRIDGE:-pxebr} +LAB_NAME=${NODE_NAME/-*} +POD_NAME=${NODE_NAME/*-} + +# we currently support enea +if [[ ! "$LAB_NAME" =~ "enea" ]]; then + echo "Unsupported/unidentified lab $LAB_NAME. Cannot continue!" + exit 1 +else + echo "Using configuration for $LAB_NAME" +fi + +# create TMPDIR if it doesn't exist +mkdir -p $TMPDIR + +cd $WORKSPACE +if [[ $LAB_CONFIG_URL =~ ^git:// ]]; then + git clone --quiet --branch ${GIT_BRANCH##origin/} $LAB_CONFIG_URL lab-config + LAB_CONFIG_URL=file://${WORKSPACE}/lab-config +fi + +# construct the command +DEPLOY_COMMAND="$WORKSPACE/ci/deploy.sh -b ${LAB_CONFIG_URL} -l $LAB_NAME -p $POD_NAME -s $DEPLOY_SCENARIO -i file://$WORKSPACE/opnfv.iso -H -B $BRIDGE -S $TMPDIR" + +# log info to console +echo "Deployment parameters" +echo "--------------------------------------------------------" +echo "Scenario: $DEPLOY_SCENARIO" +echo "Lab: $LAB_NAME" +echo "POD: $POD_NAME" +echo "ISO: ${OPNFV_ARTIFACT_URL/*\/}" +echo +echo "Starting the deployment using $INSTALLER_TYPE. This could take some time..." +echo "--------------------------------------------------------" +echo + +# start the deployment +echo "Issuing command" +echo "$DEPLOY_COMMAND" +echo + +$DEPLOY_COMMAND + +echo +echo "--------------------------------------------------------" +echo "Deployment is done successfully!" diff --git a/jjb/armband/armband-download-artifact.sh b/jjb/armband/armband-download-artifact.sh new file mode 100755 index 000000000..15ad67d6e --- /dev/null +++ b/jjb/armband/armband-download-artifact.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2016 Ericsson AB and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -o errexit +set -o pipefail + +if [[ "$JOB_NAME" =~ "merge" ]]; then + echo "Downloading http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties" + # get the properties file for the Armband Fuel ISO built for a merged change + curl -s -o $WORKSPACE/latest.properties http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties +else + # get the latest.properties file in order to get info regarding latest artifact + echo "Downloading http://$GS_URL/latest.properties" + curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties +fi + +# check if we got the file +# FIXME: the file is created even if it didn't exist on the host +# We should check that the contents are sane +[[ -f latest.properties ]] || exit 1 + +# source the file so we get artifact metadata +source latest.properties + +# echo the info about artifact that is used during the deployment +OPNFV_ARTIFACT=${OPNFV_ARTIFACT_URL/*\/} +echo "Using $OPNFV_ARTIFACT for deployment" + +# using ISOs for verify & merge jobs from local storage will be enabled later +if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then + # check if we already have the ISO to avoid redownload + ISOSTORE="/iso_mount/opnfv_ci/${GIT_BRANCH##*/}" + if [[ -f "$ISOSTORE/$OPNFV_ARTIFACT" ]]; then + echo "ISO exists locally. Skipping the download and using the file from ISO store" + ln -s $ISOSTORE/$OPNFV_ARTIFACT $WORKSPACE/opnfv.iso + echo "--------------------------------------------------------" + echo + ls -al $WORKSPACE/opnfv.iso + echo + echo "--------------------------------------------------------" + echo "Done!" + exit 0 + fi +fi + +# log info to console +echo "Downloading the $INSTALLER_TYPE artifact using URL http://$OPNFV_ARTIFACT_URL" +echo "This could take some time..." +echo "--------------------------------------------------------" +echo + +# download the file +curl -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL + +# The file is always created, check that it is in fact an ISO image +[[ $(file $WORKSPACE/opnfv.iso) =~ ISO ]] + +echo +echo "--------------------------------------------------------" +echo "Done!" diff --git a/jjb/opnfv/slave-params.yml b/jjb/opnfv/slave-params.yml index 5892e7c96..f9f53ec7c 100644 --- a/jjb/opnfv/slave-params.yml +++ b/jjb/opnfv/slave-params.yml @@ -612,3 +612,15 @@ name: GIT_BASE default: https://gerrit.opnfv.org/gerrit/$PROJECT description: 'Git URL to use on this Jenkins Slave' + - string: + name: DEFAULT_BRIDGE + default: 'admin6_br0,public6_br0' + desciption: 'The bridge to use for Fuel PXE booting. It can be a comma sparated list of bridges, in which case the first is the PXE boot bridge, and all subsequent interfaces that will be added to the VM. If left empty, most deploy scripts will default to pxebr.' + - string: + name: DEPLOY_TIMEOUT + default: '360' + description: 'Deployment timeout in minutes' + - string: + name: LAB_CONFIG_URL + default: file://$HOME/opnfv/repos/lab-config + description: 'Base URI to the configuration directory' -- 2.16.6