From 2c5b848db5cde46c7c4d47a5fb6230755362285a Mon Sep 17 00:00:00 2001 From: Viktor Vorobev <vorobev@in.tum.de> Date: Thu, 7 Jan 2021 18:21:57 +0000 Subject: [PATCH] Merged in NRRPLT-8093-ci-for-ubuntu20 (pull request #49) [NRRPLT-8093] Ubuntu 20.04 Jenkins CI Approved-by: Ugo Albanese Approved-by: Krzysztof Lebioda --- .ci/build.bash | 34 +++++++++++++++++++++ Jenkinsfile | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 .ci/build.bash create mode 100644 Jenkinsfile diff --git a/.ci/build.bash b/.ci/build.bash new file mode 100644 index 0000000..62fe33f --- /dev/null +++ b/.ci/build.bash @@ -0,0 +1,34 @@ +#!/bin/bash +set -e +set -o xtrace + +whoami +env | sort +pwd + +if [ -f .ci/env ]; then + # add quotes to all vars (but do it once) + sudo sed -i -E 's/="*(.*[^"])"*$/="\1"/' .ci/env + source '.ci/env' +fi + +sudo apt-get update && sudo apt-get install -y cmake +# Declare nvm +. $HOME/.nvm/nvm.sh +. $HOME/.bashrc +# Make gazebo discoverable +export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH + + +npm install -g bower +rm -rf build/ +rm -rf gzbridge/build +sudo chown -R bbpnrsoa:bbp-ext $WORKSPACE/$GIT_CHECKOUT_DIR/http + +./deploy-gzbridge-nrp.sh + +npm dedupe +npm install --no-save +cd gz3d/utils +npm dedupe +npm install --no-save diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..0b0d7be --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,81 @@ +// Load shared library at master branch +// the path to the repo with this library should be specified in Jenkins +// https://tomd.xyz/jenkins-shared-library/ +// https://www.jenkins.io/doc/book/pipeline/shared-libraries/ +@Library('nrp-shared-libs@master') _ + +pipeline { + environment { + USER_SCRIPTS_DIR = "user-scripts" + ADMIN_SCRIPTS_DIR = "admin-scripts" + GZWEB_DIR = "gzweb" + // GIT_CHECKOUT_DIR is a dir of the main project (that was pushed) + GIT_CHECKOUT_DIR = "${env.GZWEB_DIR}" + + // define topic branch name + TOPIC_BRANCH = selectTopicBranch(env.BRANCH_NAME, env.CHANGE_BRANCH) + DEFAULT_BRANCH = 'development' + + HBP = "/home/bbpnrsoa/nrp/src" + } + agent { + docker { + // NEXUS_REGISTRY_IP and NEXUS_REGISTRY_PORT are Jenkins global variables + image "${env.NEXUS_REGISTRY_IP}:${env.NEXUS_REGISTRY_PORT}/nrp:development" + args '--entrypoint="" -u root --privileged' + } + } + options { + // Skip code checkout prior running pipeline (only Jenkinsfile is checked out) + skipDefaultCheckout true + } + + stages { + stage('Code checkout') { + steps { + // Notify BitBucket on the start of the job + // The Bitbucket Build Status Notifier is used + // REF: https://plugins.jenkins.io/bitbucket-build-status-notifier/ + + bitbucketStatusNotify(buildState: 'INPROGRESS', buildName: 'Code checkout') + + // Debug information on available environment + echo sh(script: 'env|sort', returnStdout: true) + + // Checkout main project to GIT_CHECKOUT_DIR + dir(env.GIT_CHECKOUT_DIR) { + checkout scm + sh 'sudo chown -R "${USER}" ./' + } + } + } + + stage('Build and Test gzweb') { + steps { + bitbucketStatusNotify(buildState: 'INPROGRESS', buildName: 'Building gzweb') + + // Build operations (starting in .ci directory) + dir( env.GIT_CHECKOUT_DIR){ + // Determine explicitly the shell as bash + sh 'env > .ci/env' + sh 'sudo -H -u ${USER} bash ./.ci/build.bash' + } + } + } + } + + post { + always { + cleanWs() + } + aborted { + bitbucketStatusNotify(buildState: 'FAILED', buildDescription: 'Build aborted!') + } + failure { + bitbucketStatusNotify(buildState: 'FAILED', buildDescription: 'Build failed, see console output!') + } + success{ + bitbucketStatusNotify(buildState: 'SUCCESSFUL', buildDescription: 'branch ' + env.BRANCH_NAME) + } + } +} -- GitLab