From: Alfredo Deza Date: Wed, 28 Sep 2016 19:07:59 +0000 (-0400) Subject: scripts: create helpers to post build statuses to shaman X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5a09d2f64b1f0dfbe9c459a8e0ad2737745ff20;p=ceph-build.git scripts: create helpers to post build statuses to shaman Signed-off-by: Alfredo Deza --- diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index 75108391..686e17bb 100644 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -128,3 +128,98 @@ check_binary_existence () { fi } + + +submit_build_status() { + # A helper script to post (create) the status of a build in shaman + # 'state' can be either 'failed' or 'started' + # 'project' is used to post to the right url in shaman + http_method=$1 + state=$2 + project=$3 + distro=$4 + distro_version=$5 + distro_arch=$6 + cat > $WORKSPACE/build_status.json << EOF +{ + "extra":{ + "version":"$vers", + "root_build_cause":"$ROOT_BUILD_CAUSE", + "node_name":"$NODE_NAME", + "job_name":"$JOB_NAME", + "build_user":"$BUILD_USER" + }, + "url":"$BUILD_URL", + "log_url":"$BUILD_URL/consoleFull", + "state":"$state", + "distro":"$distro", + "distro_version":"$distro_version", + "distro_arch":"$distro_arch", + "branch":"$BRANCH", + "sha1":"$SHA1", + "flavor":"$FLAVOR" +} +EOF + + SHAMAN_URL="https://shaman.ceph.com/api/builds/$project/" + # post the build information as JSON to shaman + curl -X $http_method -H "Content-Type:application/json" --data "@$WORKSPACE/build_status.json" -u $SHAMAN_API_USER:$SHAMAN_API_KEY ${SHAMAN_URL} + + +} + + +update_build_status() { + # A proxy script to PUT (update) the status of a build in shaman + # 'state' can be either of: 'started', 'completed', or 'failed' + # 'project' is used to post to the right url in shaman + + # required + state=$1 + project=$2 + + # optional + distro=$3 + distro_version=$4 + distro_arch=$5 + + submit_build_status "PUT" $state $project $distro $distro_version $distro_arch +} + + +create_build_status() { + # A proxy script to POST (create) the status of a build in shaman for + # a normal/initial build + # 'state' can be either of: 'started', 'completed', or 'failed' + # 'project' is used to post to the right url in shaman + + # required + state=$1 + project=$2 + + # optional + distro=$3 + distro_version=$4 + distro_arch=$5 + + submit_build_status "POST" $state $project $distro $distro_version $distro_arch +} + + +failed_build_status() { + # A helper script to POST (create) the status of a build in shaman as + # a failed build. The only required argument is the 'project', so that it + # can be used post to the right url in shaman + + # required + project=$1 + + state="failed" + + # optional + distro=$2 + distro_version=$3 + distro_arch=$4 + + submit_build_status "POST" $state $project $distro $distro_version $distro_arch +}