From b414145a14fd4390525cd72e55b2e49e5ad27dac Mon Sep 17 00:00:00 2001 From: David Galloway Date: Mon, 4 Jun 2018 10:36:54 -0400 Subject: [PATCH] Add job for ceph-iscsi-* stable releases Signed-off-by: David Galloway --- ceph-iscsi-stable/README.rst | 13 ++ ceph-iscsi-stable/build/build_rpm | 89 +++++++++++++ ceph-iscsi-stable/build/failure | 4 + ceph-iscsi-stable/build/setup | 52 ++++++++ ceph-iscsi-stable/build/validate_rpm | 7 + .../config/definitions/ceph-iscsi-stable.yml | 123 ++++++++++++++++++ 6 files changed, 288 insertions(+) create mode 100644 ceph-iscsi-stable/README.rst create mode 100644 ceph-iscsi-stable/build/build_rpm create mode 100644 ceph-iscsi-stable/build/failure create mode 100644 ceph-iscsi-stable/build/setup create mode 100644 ceph-iscsi-stable/build/validate_rpm create mode 100644 ceph-iscsi-stable/config/definitions/ceph-iscsi-stable.yml diff --git a/ceph-iscsi-stable/README.rst b/ceph-iscsi-stable/README.rst new file mode 100644 index 000000000..9b2605a15 --- /dev/null +++ b/ceph-iscsi-stable/README.rst @@ -0,0 +1,13 @@ +ceph-iscsi-stable +================= +This job is used to build and push RPMs to chacra.ceph.com so they can be synced, signed, then pushed to download.ceph.com. + +There are scripts in ``~/ceph-iscsi/bin`` on the signer box for pulling, signing, and pushing the RPMs. + +.. code:: + + # Example + cd /home/ubuntu/ceph-iscsi/bin + ./sync-pull 2 0784eb00a859501f90f2b1c92354ae7242d5be3d + ./sign-rpms + ./sync-push 2 diff --git a/ceph-iscsi-stable/build/build_rpm b/ceph-iscsi-stable/build/build_rpm new file mode 100644 index 000000000..4acdae569 --- /dev/null +++ b/ceph-iscsi-stable/build/build_rpm @@ -0,0 +1,89 @@ +#! /usr/bin/bash +set -ex + +# Install the dependencies +sudo yum install -y mock + +# Loop through the projects and build RPMs +# Some of this might not need to be repeated 3 times +for project in $(ls -h | grep -v dist); do + + PROJECT=$project + cd $WORKSPACE/$PROJECT + + # Get some basic information about the system and the repository + RELEASE="$(lsb_release --short -r | cut -d '.' -f 1)" # system release + VERSION="$(git describe --abbrev=0 --tags HEAD)" # for ceph-iscsi, this will return the major version number (e.g., 2) + REVISION="$(git describe --tags HEAD | cut -d - -f 2- | sed 's/-/./')" + + # Create dummy dist tar + tar cf ../dist/${PROJECT}-${VERSION}.tar.gz \ + --exclude .git --exclude dist \ + --transform "s,^,${PROJECT}-${VERSION}/," * + tar tfv ../dist/${PROJECT}-${VERSION}.tar.gz + + # Update spec version + sed -i "s/^Version:.*$/Version:\t${VERSION}/g" $WORKSPACE/$PROJECT/${PROJECT}.spec + sed -i "s/^Release:.*$/Release:\t${REVISION}%{?dist}/g" $WORKSPACE/$PROJECT/${PROJECT}.spec + # for debugging + cat $WORKSPACE/$PROJECT/${PROJECT}.spec + + # Update setup.py version + sed -i "s/version=\"[^\"]*\"/version=\"${VERSION}\"/g" $WORKSPACE/$PROJECT/setup.py + # for debugging + cat $WORKSPACE/$PROJECT/setup.py + + # Create the source rpm + echo "Building SRPM" + rpmbuild \ + --define "_sourcedir $WORKSPACE/dist" \ + --define "_specdir $WORKSPACE/dist" \ + --define "_builddir $WORKSPACE/dist" \ + --define "_srcrpmdir $WORKSPACE/dist/SRPMS" \ + --define "_rpmdir $WORKSPACE/dist/RPMS" \ + --nodeps -bs $WORKSPACE/$PROJECT/${PROJECT}.spec + SRPM=$(readlink -f $WORKSPACE/dist/SRPMS/*.src.rpm) + + # Build the binaries with mock + echo "Building RPMs" + sudo mock --verbose -r ${MOCK_TARGET}-${RELEASE}-${ARCH} --scrub=all + sudo mock --verbose -r ${MOCK_TARGET}-${RELEASE}-${ARCH} --define "dist .el7" --resultdir=$WORKSPACE/dist/RPMS/ ${SRPM} || ( tail -n +1 $WORKSPACE/dist/RPMS/{root,build}.log && exit 1 ) +done + +cd $WORKSPACE + +# All three projects should share the same major version so we'll use that +VERSION=$(echo $VERSION | cut -d '.' -f1) +# The VERSION and GIT_COMMIT aren't really important here. We just feed it the last project's info so the CI works. +chacra_endpoint="ceph-iscsi/${VERSION}/${GIT_COMMIT}/${DISTRO}/${RELEASE}" +chacra_repo_endpoint="${chacra_endpoint}/flavors/default" + +# check to make sure ceph-iscsi-config package built +if [ ! -f $WORKSPACE/dist/RPMS/ceph-iscsi-config-*.rpm ]; then + echo "ceph-iscsi-config rpm not built!" + exit 1 +fi + +# check to make sure ceph-iscsi-cli package built +if [ ! -f $WORKSPACE/dist/RPMS/ceph-iscsi-cli-*.rpm ]; then + echo "ceph-iscsi-cli rpm not built!" + exit 1 +fi + +# check to make sure ceph-iscsi-tools package built +if [ ! -f $WORKSPACE/dist/RPMS/ceph-iscsi-tools-*.rpm ]; then + echo "ceph-iscsi-tools rpm not built!" + exit 1 +fi + +[ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags="" + +if [ "$THROWAWAY" = false ] ; then + # push binaries to chacra + find $WORKSPACE/dist/SRPMS | grep rpm | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/source/ + find $WORKSPACE/dist/RPMS/ | grep rpm | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/noarch/ + # start repo creation + $VENV/chacractl repo update ${chacra_repo_endpoint} +fi + +sudo rm -rf $WORKSPACE/dist diff --git a/ceph-iscsi-stable/build/failure b/ceph-iscsi-stable/build/failure new file mode 100644 index 000000000..588863856 --- /dev/null +++ b/ceph-iscsi-stable/build/failure @@ -0,0 +1,4 @@ +#!/bin/bash -ex + +rm -f ~/.chacractl +rm -rf $WORKSPACE/* diff --git a/ceph-iscsi-stable/build/setup b/ceph-iscsi-stable/build/setup new file mode 100644 index 000000000..a9d593df4 --- /dev/null +++ b/ceph-iscsi-stable/build/setup @@ -0,0 +1,52 @@ +#! /usr/bin/bash +# +# Ceph distributed storage system +# +# Copyright (C) 2016 Red Hat +# +# Author: Boris Ranto +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# + +set -ex + +# Make sure we execute at the top level directory before we do anything +cd $WORKSPACE + +# This will set the DISTRO and MOCK_TARGET variables. +#get_distro_and_target +# I could not get that function to work so I'm hardcoding these vars. +DISTRO="centos" +MOCK_TARGET="epel" + +# Make sure the dist directory is clean +rm -rf dist +mkdir -p dist + +# Perform a clean-up +for dir in $(ls -h | grep -v dist); do + cd $WORKSPACE/$dir + git clean -fxd +done + +cd $WORKSPACE + +# Print some basic system info +HOST=$(hostname --short) +echo "Building on $(hostname) with the following env" +echo "*****" +env +echo "*****" + +export LC_ALL=C # the following is vulnerable to i18n + +pkgs=( "chacractl>=0.0.4" ) +install_python_packages "pkgs[@]" + +chacra_url="https://chacra.ceph.com/" +# create the .chacractl config file using global variables +make_chacractl_config $chacra_url diff --git a/ceph-iscsi-stable/build/validate_rpm b/ceph-iscsi-stable/build/validate_rpm new file mode 100644 index 000000000..17b414826 --- /dev/null +++ b/ceph-iscsi-stable/build/validate_rpm @@ -0,0 +1,7 @@ +#!/bin/bash +set -ex + +# only do work if we are a RPM distro +if [[ ! -f /etc/redhat-release && ! -f /usr/bin/zypper ]] ; then + exit 0 +fi diff --git a/ceph-iscsi-stable/config/definitions/ceph-iscsi-stable.yml b/ceph-iscsi-stable/config/definitions/ceph-iscsi-stable.yml new file mode 100644 index 000000000..36a78c4c4 --- /dev/null +++ b/ceph-iscsi-stable/config/definitions/ceph-iscsi-stable.yml @@ -0,0 +1,123 @@ +- scm: + name: ceph-iscsi-config + scm: + - git: + url: https://github.com/ceph/ceph-iscsi-config.git + branches: + - $CEPH_ISCSI_CONFIG_BRANCH + skip-tag: true + wipe-workspace: true + basedir: "ceph-iscsi-config" + +- scm: + name: ceph-iscsi-cli + scm: + - git: + url: https://github.com/ceph/ceph-iscsi-cli.git + branches: + - $CEPH_ISCSI_CLI_BRANCH + skip-tag: true + wipe-workspace: true + basedir: "ceph-iscsi-cli" + +- scm: + name: ceph-iscsi-tools + scm: + - git: + url: https://github.com/ceph/ceph-iscsi-tools.git + branches: + - $CEPH_ISCSI_TOOLS_BRANCH + skip-tag: true + wipe-workspace: true + basedir: "ceph-iscsi-tools" + +- job: + name: ceph-iscsi-stable + node: 'centos7 && x86_64 && huge' + project-type: freestyle + defaults: global + display-name: 'ceph-iscsi-stable' + concurrent: true + parameters: + - string: + name: CEPH_ISCSI_CONFIG_BRANCH + description: "The git branch (or tag) to build" + default: "2.6" + + - string: + name: CEPH_ISCSI_CLI_BRANCH + description: "The git branch (or tag) to build" + default: "2.7" + + - string: + name: CEPH_ISCSI_TOOLS_BRANCH + description: "The git branch (or tag) to build" + default: "2.1" + + - string: + name: DISTRO + description: "A list of distros to build for. Available options are: centos7" + default: "centos7" + + - string: + name: ARCH + description: "A list of architectures to build for. Available options are: x86_64" + default: "x86_64" + + - bool: + name: THROWAWAY + description: " +Default: False. When True it will not POST binaries to chacra. Artifacts will not be around for long. Useful to test builds." + default: false + + - bool: + name: FORCE + description: " +If this is unchecked, then nothing is built or pushed if they already exist in chacra. This is the default. + +If this is checked, then the binaries will be built and pushed to chacra even if they already exist in chacra." + default: true + + - string: + name: BUILD_VIRTUALENV + description: "Base parent path for virtualenv locations, set to avoid issues with extremely long paths that are incompatible with tools like pip. Defaults to '/tmp/' (note the trailing slash, which is required)." + default: "/tmp/" + + scm: + - ceph-iscsi-config + - ceph-iscsi-cli + - ceph-iscsi-tools + + builders: + - shell: | + echo "Cleaning up top-level workarea (shared among workspaces)" + rm -rf dist + rm -rf venv + rm -rf release + # rpm build scripts + - shell: + !include-raw: + - ../../build/validate_rpm + - ../../../scripts/build_utils.sh + - ../../build/setup + - ../../build/build_rpm + + publishers: + - postbuildscript: + builders: + - role: SLAVE + build-on: + - FAILURE + - ABORTED + build-steps: + - inject: + properties-file: ${WORKSPACE}/build_info + - shell: + !include-raw: + - ../../../scripts/build_utils.sh + - ../../build/failure + + wrappers: + - inject-passwords: + global: true + mask-password-params: true -- 2.47.3