From: Lott, Christopher (cl778h) Date: Thu, 14 Nov 2019 14:06:25 +0000 (-0500) Subject: Add build-on-merge job for pti/rpt Yocto X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=d59c1b853f8ebe41878ce7742480d94269b35c9f;p=ci-management.git Add build-on-merge job for pti/rpt Yocto Extend templates to provision global and project settings, and to create netrc using mvn-site-id. Refactor shell scripts into prereqs, verify, build and upload. First draft of upload commands that deploy ISO to nexus. Signed-off-by: Lott, Christopher (cl778h) Change-Id: Ibce18bcdf05d99844673ba782d392379795ee945 --- diff --git a/jjb/oran-jjb/oran-shell-jobs.yaml b/jjb/oran-jjb/oran-shell-jobs.yaml index 3b688536..4c5aa5a0 100644 --- a/jjb/oran-jjb/oran-shell-jobs.yaml +++ b/jjb/oran-jjb/oran-shell-jobs.yaml @@ -29,6 +29,7 @@ disable-job: false gerrit-skip-vote: false git-url: '$GIT_URL/$GERRIT_PROJECT' + mvn-global-settings: global-settings stream: master submodule-disable: false submodule-recursive: true @@ -66,7 +67,14 @@ jenkins-ssh-credential: '{jenkins-ssh-credential}' builders: + - lf-infra-pre-build + - lf-provide-maven-settings: + global-settings-file: "{mvn-global-settings}" + settings-file: "{mvn-settings}" + - lf-infra-create-netrc: + server-id: "{mvn-site-id}" - shell: '{script}' + - lf-provide-maven-settings-cleanup publishers: - lf-infra-publish diff --git a/jjb/pti-rtp/build-yocto.sh b/jjb/pti-rtp/build-yocto.sh new file mode 100644 index 00000000..5e9fbdca --- /dev/null +++ b/jjb/pti-rtp/build-yocto.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright (C) 2019 Wind River Systems, Inc. +# +# 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. + +# Builds a Yocto image for real. +# Assumes prereqs have already been installed. + +echo "--> build-yocto.sh" + +# Ensure we fail the job if any steps fail. +set -eu -o pipefail + +dir=workspace +echo "INFO: creating workspace $dir" +mkdir $dir +cmd="./scripts/build_oran.sh -w $dir" +echo "INFO: invoking build script: $cmd" +$cmd + +echo "--> build-yocto.sh ends" diff --git a/jjb/pti-rtp/verify-pti-rtp-centos.sh b/jjb/pti-rtp/install-yocto-prereq-centos.sh old mode 100755 new mode 100644 similarity index 75% rename from jjb/pti-rtp/verify-pti-rtp-centos.sh rename to jjb/pti-rtp/install-yocto-prereq-centos.sh index 15645511..55c2abc8 --- a/jjb/pti-rtp/verify-pti-rtp-centos.sh +++ b/jjb/pti-rtp/install-yocto-prereq-centos.sh @@ -14,10 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Installs prerequisites on CentOS then invokes the pti/rtp build script -# to test creation of a Yocto image. The "-n" flag skips bitbake. +# Installs Yocto build prerequisites on CentOS. -echo "--> verify-pti-rtp-centos.sh" +echo "--> install-yocto-prereq-centos.sh" # Ensure we fail the job if any steps fail. set -eu -o pipefail @@ -31,11 +30,4 @@ sudo yum install -y epel-release \ && sudo yum makecache \ && sudo yum install -y $pkgs -dir=workspace -echo "INFO: creating workspace $dir" -mkdir $dir -cmd="./scripts/build_oran.sh -w $dir -n" -echo "INFO: invoking build script: $cmd" -$cmd - -echo "--> verify-pti-rtp-centos.sh ends" +echo "--> install-yocto-prereq-centos.sh ends" diff --git a/jjb/pti-rtp/pti-rtp.yaml b/jjb/pti-rtp/pti-rtp.yaml index 14f231e6..07fd3c44 100644 --- a/jjb/pti-rtp/pti-rtp.yaml +++ b/jjb/pti-rtp/pti-rtp.yaml @@ -13,14 +13,36 @@ jobs: - gerrit-info-yaml-verify -- project: - name: pti-rtp-verify +- pti_rtp_common: &pti_rtp_common + name: pti-rtp-common + # git repo project: pti/rtp + # jenkins job name prefix project-name: pti-rtp + # maven settings file has credentials + mvn-settings: pti-rtp-settings # use a centos with big memory; docker not required build-node: centos7-docker-2c-8g - # runs about 30 minutes + +- project: + <<: *pti_rtp_common + name: pti-rtp-verify + # runs about 40 minutes build-timeout: 60 - script: !include-raw-escape: verify-pti-rtp-centos.sh + script: !include-raw-escape: + - install-yocto-prereq-centos.sh + - verify-yocto.sh jobs: - oran-shell-verify + +- project: + <<: *pti_rtp_common + name: pti-rtp-merge + # runs about 9 hours + build-timeout: 600 + script: !include-raw-escape: + - install-yocto-prereq-centos.sh + - build-yocto.sh + - upload-yocto.sh + jobs: + - oran-shell-merge diff --git a/jjb/pti-rtp/upload-yocto.sh b/jjb/pti-rtp/upload-yocto.sh new file mode 100644 index 00000000..35b4baea --- /dev/null +++ b/jjb/pti-rtp/upload-yocto.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (C) 2019 Wind River Systems, Inc. +# +# 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. + +# Uploads a Yocto image to Nexus. + +echo "--> upload-yocto.sh" + +# Ensure we fail the job if any steps fail. +set -eu -o pipefail + +echo "INFO: creating virtual environment" +virtualenv -p python3 /tmp/venv +PATH=/tmp/venv/bin:$PATH +pipup="python -m pip install -q --upgrade lftools" +echo "INFO: installing packages: $pipup" +$pipup + +# NEXUS_URL is set by Jenkins +nexus_repo_id="images" +nexus_repo_url="$NEXUS_URL/content/sites/$nexus_repo_id" +echo "INFO: upload to $nexus_repo_url" + +repo_dir="$WORKSPACE/nexus/$nexus_repo_id" +# TODO: get build or version string; use latest for now +repo_iso_dir="$repo_dir/org/o-ran-sc/pti/rtp/latest" +echo "INFO: create staging directory $repo_iso_dir" +mkdir -p "$repo_iso_dir" + +# Expect ISO file: oran-image-inf-host-intel-x86-64.iso +# in build subdir: workspace/prj_oran-inf/tmp-glibc/deploy/images/intel-x86-64/ +iso="workspace/prj_oran-inf/tmp-glibc/deploy/images/intel-x86-64/oran-image-inf-host-intel-x86-64.iso" +echo "INFO: copy $iso to staging directory $repo_iso_dir" +cp "$iso" "$repo_iso_dir" + +cmd="lftools deploy nexus $nexus_repo_url $repo_dir" +echo "INFO: Upload ISO to Nexus: $cmd" +$cmd + +echo "--> upload-yocto.sh ends" diff --git a/jjb/pti-rtp/verify-yocto.sh b/jjb/pti-rtp/verify-yocto.sh new file mode 100644 index 00000000..da13788f --- /dev/null +++ b/jjb/pti-rtp/verify-yocto.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright (C) 2019 Wind River Systems, Inc. +# +# 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. + +# Tests creation of a Yocto image. The "-n" flag skips bitbake. +# Assumes prereqs have already been installed. + +echo "--> verify-yocto.sh" + +# Ensure we fail the job if any steps fail. +set -eu -o pipefail + +dir=workspace +echo "INFO: creating workspace $dir" +mkdir $dir +cmd="./scripts/build_oran.sh -w $dir -n" +echo "INFO: invoking build script: $cmd" +$cmd + +echo "--> verify-yocto.sh ends"