Fix determine email body script

pull/12890/head
Madhura Bhave 7 years ago
parent 8d4e5cbfb7
commit 68a9aa56f0

@ -7,5 +7,7 @@ docker-hub-organization: "springci"
artifactory-server: "https://repo.spring.io/" artifactory-server: "https://repo.spring.io/"
branch: "2.0.x" branch: "2.0.x"
build-name: "spring-boot" build-name: "spring-boot"
pipeline-name: "spring-boot-2.0.x"
concourse-url: "https://ci.spring.io"
bintray-subject: "spring" bintray-subject: "spring"
bintray-repo: "jars" bintray-repo: "jars"

@ -142,6 +142,9 @@ jobs:
file: git-repo/ci/tasks/determine-email-body.yml file: git-repo/ci/tasks/determine-email-body.yml
params: params:
STATE: failure STATE: failure
BUILD_PIPELINE_NAME: ((pipeline-name))
BUILD_JOB_NAME: build
CONCOURSE_URL: ((concourse-url))
- put: email-notification - put: email-notification
params: params:
subject: email-details/subject subject: email-details/subject
@ -152,6 +155,9 @@ jobs:
file: git-repo/ci/tasks/determine-email-body.yml file: git-repo/ci/tasks/determine-email-body.yml
params: params:
STATE: success STATE: success
BUILD_PIPELINE_NAME: ((pipeline-name))
BUILD_JOB_NAME: build
CONCOURSE_URL: ((concourse-url))
- put: repo-status-build - put: repo-status-build
params: { state: "success", commit: "git-repo" } params: { state: "success", commit: "git-repo" }
- put: email-notification - put: email-notification

@ -1,24 +1,25 @@
#!/bin/bash #!/bin/bash
set -e set -e
PREV_SHA=$(git rev-parse HEAD^1) pushd git-repo > /dev/null
PREV_SHA=$(git rev-parse HEAD^1)
popd > /dev/null
PREV_STATUSES=$(curl https://api.github.com/repos/spring-projects/spring-boot/commits/$PREV_SHA/statuses) PREV_STATUSES=$(curl https://api.github.com/repos/spring-projects/spring-boot/commits/$PREV_SHA/statuses)
PREV_STATES=echo $PREV_STATUSES | jq -r '.[] | select(.context == "build") | .state' PREV_STATES=$(echo $PREV_STATUSES | jq -r --arg BUILD_JOB_NAME "$BUILD_JOB_NAME" '.[] | select(.context == $BUILD_JOB_NAME) | .state')
WAS_PREV_SUCCESSFUL=$(echo $PREV_STATES | grep 'success') WAS_PREV_SUCCESSFUL=$(echo $PREV_STATES | grep 'success')
if [[ $STATE == "success" ]];then if [[ $STATE == "success" ]];then
echo "Build SUCCESSFUL ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME} / ${BUILD_NAME}" > email-details/subject echo "Build SUCCESSFUL ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME}" > email-details/subject
if [[ $WAS_PREV_SUCCESSFUL == "" ]];then if [[ $WAS_PREV_SUCCESSFUL == "" ]];then
echo "Build ${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME} is successful!" > email-details/body echo "Build ${CONCOURSE_URL}/teams/spring-boot/pipelines/${BUILD_PIPELINE_NAME} is successful!" > email-details/body
elif [[ $WAS_PREV_SUCCESSFUL == "success" ]];then elif [[ $WAS_PREV_SUCCESSFUL == "success" ]];then
echo "" > email-details/body touch email-details/body
fi fi
fi
elif [[ $STATE == "failure" ]];then elif [[ $STATE == "failure" ]];then
echo "Build ${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME} has failed!" > email-details/body echo "Build ${CONCOURSE_URL}/teams/spring-boot/pipelines/${BUILD_PIPELINE_NAME} has failed!" > email-details/body
if [[ $WAS_PREV_SUCCESSFUL == "" ]];then if [[ $WAS_PREV_SUCCESSFUL == "" ]];then
echo "Still FAILING ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME} / ${BUILD_NAME}" > email-details/subject echo "Still FAILING ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME}" > email-details/subject
elif [[ $WAS_PREV_SUCCESSFUL == "success" ]];then elif [[ $WAS_PREV_SUCCESSFUL == "success" ]];then
echo "Build FAILURE ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME} / ${BUILD_NAME}" > email-details/subject echo "Build FAILURE ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME}" > email-details/subject
fi fi
fi fi

Loading…
Cancel
Save