]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
build_utils.sh: Add chacra_post functions wip-chacra-post 547/head
authorBoris Ranto <branto@redhat.com>
Wed, 16 Nov 2016 13:51:13 +0000 (14:51 +0100)
committerBoris Ranto <branto@redhat.com>
Thu, 17 Nov 2016 14:44:45 +0000 (15:44 +0100)
These functions can later be re-used by ~all the builder jobs to upload
their packages and create the chacra repository.

Signed-off-by: Boris Ranto <branto@redhat.com>
scripts/build_utils.sh

index 984a216e64155bb79f4932d959d1e37b58e50454..4ee43bd12f9415f1dcee92ed25d38f7fd38a03ca 100644 (file)
@@ -391,3 +391,79 @@ setup_pbuilder() {
         --mirror "$mirror"
     fi
 }
+
+
+chacra_post_deb_packages() {
+    if test $# -lt 2; then
+        echo "ERROR: Incorrect usage"
+        echo "Usage: <function> <chacra_endpoint> <package> [package...]"
+        exit 1
+    fi
+
+    local chacra_endpoint="$1"
+    shift
+    local arch=$(dpkg-architecture -qDEB_BUILD_ARCH)
+    local pkg pkg_version chacra_flags
+    test "$FORCE" = true && chacra_flags="--force"
+
+    for pkg in $@; do
+        pkg_version=$(dpkg-deb -f "$pkg" Version)
+        $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/${arch}/ "$pkg"
+    done
+
+    # write json file with build info
+    cat > $WORKSPACE/repo-extra.json << EOF
+{
+    "package_manager_version":"$pkg_version",
+    "build_url":"$BUILD_URL",
+    "root_build_cause":"$ROOT_BUILD_CAUSE",
+    "node_name":"$NODE_NAME",
+    "job_name":"$JOB_NAME"
+}
+EOF
+    # post the json to repo-extra json to chacra
+    curl -X POST -H "Content-Type:application/json" --data "@$WORKSPACE/repo-extra.json" -u $CHACRACTL_USER:$CHACRACTL_KEY https://chacra.ceph.com/repos/${chacra_endpoint}/extra/
+
+    # start repo creation
+    $VENV/chacractl repo update ${chacra_endpoint}
+
+    echo Check the status of the repo at: https://shaman.ceph.com/api/repos/${chacra_endpoint}
+}
+
+
+chacra_post_rpm_packages() {
+    if test $# -lt 2; then
+        echo "ERROR: Incorrect usage"
+        echo "Usage: <function> <chacra_endpoint> <package> [package...]"
+        exit 1
+    fi
+
+    local chacra_endpoint="$1"
+    shift
+    local arch=${ARCH}
+    local pkg pkg_version chacra_flags
+    test "$FORCE" = true && chacra_flags="--force"
+
+    for pkg in $@; do
+        pkg_version=$(rpm --queryformat '%{VERSION}-%{RELEASE}\n' -qp "$pkg")
+        $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/${arch}/ "$pkg"
+    done
+
+    # write json file with build info
+    cat > $WORKSPACE/repo-extra.json << EOF
+{
+    "package_manager_version":"$pkg_version",
+    "build_url":"$BUILD_URL",
+    "root_build_cause":"$ROOT_BUILD_CAUSE",
+    "node_name":"$NODE_NAME",
+    "job_name":"$JOB_NAME"
+}
+EOF
+    # post the json to repo-extra json to chacra
+    curl -X POST -H "Content-Type:application/json" --data "@$WORKSPACE/repo-extra.json" -u $CHACRACTL_USER:$CHACRACTL_KEY https://chacra.ceph.com/repos/${chacra_endpoint}/extra/
+
+    # start repo creation
+    $VENV/chacractl repo update ${chacra_endpoint}
+
+    echo Check the status of the repo at: https://shaman.ceph.com/api/repos/${chacra_endpoint}
+}