From 65a78e213ec8508ab57205ccc6283c0492a410bb Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Thu, 2 May 2019 09:23:43 +0200 Subject: [PATCH] Add new job for deploying kni on AWS Change-Id: Ieae618b9dfe99880f218cb409d328106633419e8 Signed-off-by: Eric Ball --- jjb/akraino-templates/akraino-jjb-kni.yaml | 189 +++++++++++++++++++++++++++++ jjb/kni/kni_installer.yaml | 9 ++ jjb/shell/kni_deploy_aws.sh | 58 +++++++++ 3 files changed, 256 insertions(+) create mode 100755 jjb/shell/kni_deploy_aws.sh diff --git a/jjb/akraino-templates/akraino-jjb-kni.yaml b/jjb/akraino-templates/akraino-jjb-kni.yaml index d3febe2..31429fb 100644 --- a/jjb/akraino-templates/akraino-jjb-kni.yaml +++ b/jjb/akraino-templates/akraino-jjb-kni.yaml @@ -168,3 +168,192 @@ - ../shell/install_go.sh - shell: !include-raw-escape: - ../shell/build_kni_binary.sh + +- job-template: + id: kni-installer-merge-deploy-aws + name: '{project-name}-merge-deploy-aws' + + ###################### + # Default parameters # + ###################### + + archive-artifacts: > + **/*.log + build-days-to-keep: 30 + build-timeout: 60 + build-node: centos7-builder-8c-8g + submodule-recursive: true + + ##################### + # Job Configuration # + ##################### + + project-type: freestyle + node: '{build-node}' + + properties: + - lf-infra-properties: + build-days-to-keep: '{build-days-to-keep}' + + parameters: + - lf-infra-parameters: + project: '{project}' + branch: '{branch}' + stream: '{stream}' + lftools-version: '{lftools-version}' + - string: + name: ARCHIVE_ARTIFACTS + default: '{archive-artifacts}' + description: Artifacts to archive to the logs server. + + wrappers: + - lf-infra-wrappers: + build-timeout: '{build-timeout}' + jenkins-ssh-credential: '{jenkins-ssh-credential}' + - credentials-binding: + - ssh-user-private-key: + credential-id: kni-secrets + key-file-variable: KNI_KEY_PATH + + gerrit_trigger_file_paths: + - compare-type: REG_EXP + pattern: '.*' + + gerrit_merge_triggers: + - change-merged-event + - comment-added-contains-event: + comment-contains-value: remerge$ + + scm: + - lf-infra-gerrit-scm: + jenkins-ssh-credential: '{jenkins-ssh-credential}' + git-url: '{git-url}/{project}.git' + refspec: '$GERRIT_REFSPEC' + branch: '$GERRIT_BRANCH' + submodule-recursive: '{submodule-recursive}' + submodule-timeout: '{submodule-timeout}' + choosing-strategy: default + + triggers: + - gerrit: + server-name: '{gerrit-server-name}' + trigger-on: '{obj:gerrit_merge_triggers}' + projects: + - project-compare-type: ANT + project-pattern: '{project}' + branches: + - branch-compare-type: ANT + branch-pattern: '**/{branch}' + file-paths: '{obj:gerrit_trigger_file_paths}' + + builders: + - lf-infra-pre-build + - config-file-provider: + files: + - file-id: kni-aws-access-key-id + target: akraino-secrets/aws-access-key-id + - file-id: kni-aws-secret-access-key + target: akraino-secrets/aws-secret-access-key + - file-id: kni-coreos-pull-secret + target: akraino-secrets/coreos-pull-secret + - file-id: kni-ssh-pub-key + target: akraino-secrets/ssh-pub-key + - shell: !include-raw-escape: + - ../shell/install_go.sh + - shell: !include-raw-escape: + - ../shell/kni_deploy_aws.sh + + publishers: + - lf-infra-publish + +- job-template: + id: kni-templates-verify-deploy-aws + name: '{project-name}-verify-deploy-aws' + + ###################### + # Default parameters # + ###################### + + build-days-to-keep: 30 + build-timeout: 60 + build-node: centos7-builder-8c-8g + submodule-recursive: true + + ##################### + # Job Configuration # + ##################### + + project-type: freestyle + node: '{build-node}' + + properties: + - lf-infra-properties: + build-days-to-keep: '{build-days-to-keep}' + + parameters: + - lf-infra-parameters: + project: '{project}' + branch: '{branch}' + stream: '{stream}' + lftools-version: '{lftools-version}' + + wrappers: + - lf-infra-wrappers: + build-timeout: '{build-timeout}' + jenkins-ssh-credential: '{jenkins-ssh-credential}' + - credentials-binding: + - ssh-user-private-key: + credential-id: kni-secrets + key-file-variable: KNI_KEY_PATH + + gerrit_trigger_file_paths: + - compare-type: REG_EXP + pattern: 'aws/*' + + scm: + - lf-infra-gerrit-scm: + jenkins-ssh-credential: '{jenkins-ssh-credential}' + git-url: '{git-url}/kni/installer.git' + refspec: '$GERRIT_REFSPEC' + branch: '$GERRIT_BRANCH' + submodule-recursive: '{submodule-recursive}' + submodule-timeout: '{submodule-timeout}' + choosing-strategy: default + + gerrit_verify_triggers: + - patchset-created-event: + exclude-drafts: true + exclude-trivial-rebase: false + exclude-no-code-change: false + - draft-published-event + - comment-added-contains-event: + comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$' + + triggers: + - gerrit: + server-name: '{gerrit-server-name}' + trigger-on: '{obj:gerrit_verify_triggers}' + projects: + - project-compare-type: ANT + project-pattern: '{project}' + branches: + - branch-compare-type: ANT + branch-pattern: '**/{branch}' + file-paths: '{obj:gerrit_trigger_file_paths}' + + builders: + - lf-infra-pre-build + - config-file-provider: + files: + - file-id: kni-aws-access-key-id + target: akraino-secrets/aws-access-key-id + - file-id: kni-aws-secret-access-key + target: akraino-secrets/aws-secret-access-key + - file-id: kni-coreos-pull-secret + target: akraino-secrets/coreos-pull-secret + - file-id: kni-ssh-pub-key + target: akraino-secrets/ssh-pub-key + - shell: !include-raw-escape: + - ../shell/install_go.sh + - shell: !include-raw-escape: + - ../shell/kni_deploy_aws.sh diff --git a/jjb/kni/kni_installer.yaml b/jjb/kni/kni_installer.yaml index 6b4ee34..90dfca1 100644 --- a/jjb/kni/kni_installer.yaml +++ b/jjb/kni/kni_installer.yaml @@ -8,3 +8,12 @@ jobs: - kni-installer-build-installer - kni-installer-build-binary + - kni-installer-merge-deploy-aws +- project: + name: kni-templates + project: 'kni/templates' + project-name: kni-templates + stream: master + branch: master + jobs: + - kni-templates-verify-deploy-aws diff --git a/jjb/shell/kni_deploy_aws.sh b/jjb/shell/kni_deploy_aws.sh new file mode 100755 index 0000000..ce8eec5 --- /dev/null +++ b/jjb/shell/kni_deploy_aws.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Copyright (c) 2019 Red Hat +# +# 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. + +export PATH=$PATH:/usr/local/go/bin +KNI_PATH='go/src/gerrit.akraino.org/kni/' + +set -e -u -x -o pipefail + +echo '---> Starting kni installer generation' + +mkdir -p $HOME/${KNI_PATH}/installer +export GOPATH=$HOME/go + +# move clone to gopath +cp -R ${WORKSPACE}/* $HOME/${KNI_PATH}/installer/ + +# first build kni installer +pushd $HOME/${KNI_PATH}/installer +make build 2>&1 | tee ${WORKSPACE}/build.log + +# then start aws deploy +export CREDENTIALS=file://$(pwd)/akraino-secrets +export BASE_REPO="git::https://gerrit.akraino.org/r/kni/templates" +export BASE_PATH="aws/3-node" +export SITE_REPO="git::https://gerrit.akraino.org/r/kni/templates" +export SETTINGS_PATH="aws/sample_settings.yaml" +make deploy 2>&1 | tee ${WORKSPACE}/aws_deploy.log +STATUS=$? + +# output tfstate +echo "metadata.json for removing cluster" +cat $(pwd)/build/metadata.json + +if [ $STATUS -ne 0 ]; then + echo "Error deploying in AWS" + exit 1 +fi + +echo "Cluster successfully deployed! Starting cleanup" +make clean +STATUS=$? + +popd + +exit $STATUS -- 2.16.6