Commit 8a9ddd42 authored by Waqas Riaz's avatar Waqas Riaz

added manual jobs to build/promote/deploy all

parent 9dcd3c7f
Pipeline #4180 skipped with stages
......@@ -3,6 +3,9 @@ stages:
- deploy_dashboards
- build_alerts
- deploy_alerts
- manual_build_all
- manual_promote_artifacts_all
- manual_deploy_all
build_dashboards_job:
stage: build_dashboards
......@@ -76,4 +79,42 @@ deploy_alerts_job:
changes:
- alerts/*
tags:
- cd
\ No newline at end of file
- cd
manual_build_all_job:
stage: manual_build_all
before_script:
- curl --version
- jsonnet --version
- tar --version
script:
- echo "Manually building all jsonnets"
- scripts/build_all.sh
tags:
- ci
when: manual
manual_promote_artifacts_all_job:
stage: manual_promote_artifacts_all
before_script:
- curl --version
- tar --version
script:
- echo "Manually promoting all artifacts to artifactory"
- scripts/promote_all_artifacts.sh
tags:
- ci
when: manual
manual_deploy_all_job:
stage: manual_deploy_all
before_script:
- curl --version
- jq --version
- tar --version
script:
- echo "Manually deploying all artifacts"
- scripts/deploy_all.sh
tags:
- cd
when: manual
\ No newline at end of file
......@@ -15,9 +15,9 @@ function build_alerts {
mkdir -p ${ALERTS_BUILD_PATH}
echo "Cleaning up previous builds"
rm -rf ${ALERTS_BUILD_PATH}/*.json
rm -rf ${ALERTS_BUILD_PATH}/*
ALERTS_JSONNETS=$(find ALERTS_JSONNET_PATH -type f -name "*.jsonnet" | xargs -I{} basename {} )
ALERTS_JSONNETS=$(find ${ALERTS_JSONNET_PATH} -type f -name "*.jsonnet" | xargs -I{} basename {} )
for json_file in ${ALERTS_JSONNETS[@]};
do
......@@ -45,7 +45,7 @@ function build_dashboards {
mkdir -p ${DASHBOARDS_BUILD_PATH}
echo "Cleaning up previous builds"
rm -rf ${DASHBOARDS_BUILD_PATH}/*.json
rm -rf ${DASHBOARDS_BUILD_PATH}/*
DASHBOARDS_JSONNETS=$(find ${DASHBOARDS_JSONNET_PATH} -type f -name "*.jsonnet" | xargs -I{} basename {} )
......@@ -65,10 +65,10 @@ function build_dashboards {
}
if [ $1 == "alerts" ]; then
if [[ $1 == "alerts" ]]; then
echo "Building only alerts"
build_alerts
elif [ $1 == "dashboards" ]; then
elif [[ $1 == "dashboards" ]]; then
echo "Building only dashboards"
build_dashboards
else
......
#!/bin/bash
TAR_NAME=all_artifacts
DEPLOY_DIR=build/$CI_PIPELINE_ID/${TAR_NAME}
CURRENT_DIR=$PWD
mkdir -p ${CURRENT_DIR}/${DEPLOY_DIR}
cd ${CURRENT_DIR}/${DEPLOY_DIR}
echo "Cleaning up previous archives"
rm -rf ${CURRENT_DIR}/${DEPLOY_DIR}/*
echo "Downloading artifact from $ARTIFACTORY_URL/grafonet/$CI_PIPELINE_ID/${TAR_NAME}.tar.gz"
curl -O -u $ARTIFACTORY_USER:$ARTIFACTORY_PASS "$ARTIFACTORY_URL/grafonet/$CI_PIPELINE_ID/${TAR_NAME}.tar.gz"
ls -larth
pwd
mkdir -p ${TAR_NAME}
tar -xzvf ${TAR_NAME}.tar.gz -C ${CURRENT_DIR}/${DEPLOY_DIR}/${TAR_NAME}
cd ${TAR_NAME}
ls -larth
echo "deploying dashboards"
cd dashboards
for FILE in *;
do
echo "$FILE \n";
DASHBOARD="{\"dashboard\": $(jq . $FILE), \"overwrite\": true}"
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$DASHBOARD" \
$GRAFANA_URL/api/dashboards/db
echo "\n"
done
cd ..
echo "deploying alerts"
cd alerts
ls -larth
for FILE in *;
do
echo "$FILE \n";
PAYLOAD="$(jq . $FILE)"
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
$GRAFANA_URL/api/v1/provisioning/alert-rules
echo "\n"
done
cd ${CURRENT_DIR}
echo "deployment completed"
\ No newline at end of file
#!/bin/bash
BUILD_PATH=build
TAR_NAME=all_artifacts
ARCHIVE_PATH=build/archive
CURRENT_DIR=$PWD
mkdir -p ${CURRENT_DIR}/${ARCHIVE_PATH}
echo "Cleaning up previous archives"
rm -rf ${CURRENT_DIR}/${ARCHIVE_PATH}/${TAR_NAME}.tar.gz
echo "Adding dashboard files to archive"
cd ${BUILD_PATH}
count_file=`ls -1 dashboards/*.json 2>/dev/null | wc -l`
echo "${count_file} json files found at `pwd`"
if [ $count_file != 0 ]
then
tar -cvzf ${CURRENT_DIR}/${ARCHIVE_PATH}/${TAR_NAME}.tar.gz dashboards alerts
ls -larth ${CURRENT_DIR}/${ARCHIVE_PATH}
echo "Uploading to $ARTIFACTORY_URL/grafonet/$CI_PIPELINE_ID/${TAR_NAME}.tar.gz"
curl -u $ARTIFACTORY_USER:$ARTIFACTORY_PASS -T ${CURRENT_DIR}/${ARCHIVE_PATH}/${TAR_NAME}.tar.gz "$ARTIFACTORY_URL/grafonet/$CI_PIPELINE_ID/${TAR_NAME}.tar.gz"
echo "Artifact Uploaded Successfully"
else
echo "ERROR: No json files found at ${BUILD_PATH}/dashboards. Build process Failed"
ls -larth ${BUILD_PATH}/dashboards
exit 1
fi
cd ${CURRENT_DIR}
echo "adding alert files to archive"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment