parent
2c6465abdc
commit
1758d8c106
|
|
@ -4,10 +4,6 @@ resource_types:
|
|||
source:
|
||||
repository: springio/artifactory-resource
|
||||
tag: 0.0.3
|
||||
- name: email
|
||||
type: docker-image
|
||||
source:
|
||||
repository: pcfseceng/email-resource
|
||||
- name: pull-request
|
||||
type: docker-image
|
||||
source:
|
||||
|
|
@ -65,16 +61,6 @@ resources:
|
|||
username: ((artifactory-username))
|
||||
password: ((artifactory-password))
|
||||
build_name: ((build-name))
|
||||
- name: email-notification
|
||||
type: email
|
||||
source:
|
||||
smtp:
|
||||
host: ((email-server))
|
||||
port: "25"
|
||||
anonymous: true
|
||||
skip_ssl_validation: true
|
||||
from: ((email-from))
|
||||
to: ((email-to))
|
||||
- name: repo-status-build
|
||||
type: github-status-resource
|
||||
source:
|
||||
|
|
@ -146,41 +132,14 @@ jobs:
|
|||
do:
|
||||
- put: repo-status-build
|
||||
params: { state: "failure", commit: "git-repo" }
|
||||
- task: determine-email-body
|
||||
image: spring-boot-ci-image
|
||||
file: git-repo/ci/tasks/determine-email-body.yml
|
||||
params:
|
||||
STATE: failure
|
||||
BUILD_PIPELINE_NAME: ((pipeline-name))
|
||||
BUILD_JOB_NAME: build
|
||||
CONCOURSE_URL: ((concourse-url))
|
||||
ACCESS_TOKEN: ((github-access-token))
|
||||
- put: email-notification
|
||||
params:
|
||||
subject: email-details/subject
|
||||
body: email-details/body
|
||||
- put: slack-alert
|
||||
params:
|
||||
text: ":concourse-failed: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed!>"
|
||||
silent: true
|
||||
icon_emoji: ":concourse:"
|
||||
username: concourse-ci
|
||||
- do:
|
||||
- task: determine-email-body
|
||||
image: spring-boot-ci-image
|
||||
file: git-repo/ci/tasks/determine-email-body.yml
|
||||
params:
|
||||
STATE: success
|
||||
BUILD_PIPELINE_NAME: ((pipeline-name))
|
||||
BUILD_JOB_NAME: build
|
||||
CONCOURSE_URL: ((concourse-url))
|
||||
ACCESS_TOKEN: ((github-access-token))
|
||||
- put: repo-status-build
|
||||
params: { state: "success", commit: "git-repo" }
|
||||
- put: email-notification
|
||||
params:
|
||||
subject: email-details/subject
|
||||
body: email-details/body
|
||||
- put: slack-alert
|
||||
params:
|
||||
text: ":concourse-succeeded: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful!>"
|
||||
|
|
@ -235,41 +194,14 @@ jobs:
|
|||
do:
|
||||
- put: repo-status-jdk9-build
|
||||
params: { state: "failure", commit: "git-repo" }
|
||||
- task: determine-email-body
|
||||
image: spring-boot-jdk9-ci-image
|
||||
file: git-repo/ci/tasks/determine-email-body.yml
|
||||
params:
|
||||
STATE: failure
|
||||
BUILD_PIPELINE_NAME: ((pipeline-name))
|
||||
BUILD_JOB_NAME: jdk9-build
|
||||
CONCOURSE_URL: ((concourse-url))
|
||||
ACCESS_TOKEN: ((github-access-token))
|
||||
- put: email-notification
|
||||
params:
|
||||
subject: email-details/subject
|
||||
body: email-details/body
|
||||
- put: slack-alert
|
||||
params:
|
||||
text: ":concourse-failed: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed!>"
|
||||
silent: true
|
||||
icon_emoji: ":concourse:"
|
||||
username: concourse-ci
|
||||
- do:
|
||||
- task: determine-email-body
|
||||
image: spring-boot-jdk9-ci-image
|
||||
file: git-repo/ci/tasks/determine-email-body.yml
|
||||
params:
|
||||
STATE: success
|
||||
BUILD_PIPELINE_NAME: ((pipeline-name))
|
||||
BUILD_JOB_NAME: jdk9-build
|
||||
CONCOURSE_URL: ((concourse-url))
|
||||
ACCESS_TOKEN: ((github-access-token))
|
||||
- put: repo-status-jdk9-build
|
||||
params: { state: "success", commit: "git-repo" }
|
||||
- put: email-notification
|
||||
params:
|
||||
subject: email-details/subject
|
||||
body: email-details/body
|
||||
- put: slack-alert
|
||||
params:
|
||||
text: ":concourse-succeeded: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful!>"
|
||||
|
|
@ -308,41 +240,14 @@ jobs:
|
|||
do:
|
||||
- put: repo-status-jdk10-build
|
||||
params: { state: "failure", commit: "git-repo" }
|
||||
- task: determine-email-body
|
||||
image: spring-boot-jdk10-ci-image
|
||||
file: git-repo/ci/tasks/determine-email-body.yml
|
||||
params:
|
||||
STATE: failure
|
||||
BUILD_PIPELINE_NAME: ((pipeline-name))
|
||||
BUILD_JOB_NAME: jdk10-build
|
||||
CONCOURSE_URL: ((concourse-url))
|
||||
ACCESS_TOKEN: ((github-access-token))
|
||||
- put: email-notification
|
||||
params:
|
||||
subject: email-details/subject
|
||||
body: email-details/body
|
||||
- put: slack-alert
|
||||
params:
|
||||
text: ":concourse-failed: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed!>"
|
||||
silent: true
|
||||
icon_emoji: ":concourse:"
|
||||
username: concourse-ci
|
||||
- do:
|
||||
- task: determine-email-body
|
||||
image: spring-boot-jdk10-ci-image
|
||||
file: git-repo/ci/tasks/determine-email-body.yml
|
||||
params:
|
||||
STATE: success
|
||||
BUILD_PIPELINE_NAME: ((pipeline-name))
|
||||
BUILD_JOB_NAME: jdk10-build
|
||||
CONCOURSE_URL: ((concourse-url))
|
||||
ACCESS_TOKEN: ((github-access-token))
|
||||
- put: repo-status-jdk10-build
|
||||
params: { state: "success", commit: "git-repo" }
|
||||
- put: email-notification
|
||||
params:
|
||||
subject: email-details/subject
|
||||
body: email-details/body
|
||||
- put: slack-alert
|
||||
params:
|
||||
text: ":concourse-succeeded: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful!>"
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd git-repo > /dev/null
|
||||
PREV_SHA=$( git rev-parse HEAD^1 )
|
||||
popd > /dev/null
|
||||
|
||||
function getPreviousSha() {
|
||||
pushd git-repo > /dev/null
|
||||
PREV_SHA=$( git rev-parse "$1"^1 )
|
||||
popd > /dev/null
|
||||
echo "$PREV_SHA"
|
||||
}
|
||||
|
||||
function getPreviousStates() {
|
||||
PREV_STATUSES=$( curl https://api.github.com/repos/spring-projects/spring-boot/commits/"$1"/statuses -H "Authorization: token ${ACCESS_TOKEN}" )
|
||||
PREV_STATES=$( echo "$PREV_STATUSES" | jq -r --arg BUILD_JOB_NAME "$BUILD_JOB_NAME" '.[] | select(.context == $BUILD_JOB_NAME) | .state' )
|
||||
echo "$PREV_STATES"
|
||||
}
|
||||
|
||||
PREV_STATES=$( getPreviousStates "$PREV_SHA" )
|
||||
WAS_PREV_SUCCESSFUL=$( echo "$PREV_STATES" | grep 'success' || true )
|
||||
IS_PREV_FAILURE=$( echo "$PREV_STATES" | grep 'failure' || true )
|
||||
|
||||
while [[ $WAS_PREV_SUCCESSFUL == "" ]] && [[ $IS_PREV_FAILURE == "" ]]; do
|
||||
PREV_SHA=$( getPreviousSha "$PREV_SHA" )
|
||||
PREV_STATES=$(getPreviousStates "$PREV_SHA")
|
||||
WAS_PREV_SUCCESSFUL=$( echo "$PREV_STATES" | grep 'success' || true )
|
||||
IS_PREV_FAILURE=$( echo "$PREV_STATES" | grep 'failure' || true )
|
||||
done
|
||||
|
||||
if [[ $STATE == "success" ]];then
|
||||
echo "Build SUCCESSFUL ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME}" > email-details/subject
|
||||
if [[ $WAS_PREV_SUCCESSFUL == "" ]];then
|
||||
echo "Build ${CONCOURSE_URL}/teams/spring-boot/pipelines/${BUILD_PIPELINE_NAME} is successful!" > email-details/body
|
||||
elif [[ $WAS_PREV_SUCCESSFUL == "success" ]];then
|
||||
touch email-details/body
|
||||
fi
|
||||
elif [[ $STATE == "failure" ]];then
|
||||
echo "Build ${CONCOURSE_URL}/teams/spring-boot/pipelines/${BUILD_PIPELINE_NAME} has failed!" > email-details/body
|
||||
if [[ $WAS_PREV_SUCCESSFUL == "" ]];then
|
||||
echo "Still FAILING ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME}" > email-details/subject
|
||||
elif [[ $WAS_PREV_SUCCESSFUL == "success" ]];then
|
||||
echo "Build FAILURE ${BUILD_PIPELINE_NAME} / ${BUILD_JOB_NAME}" > email-details/subject
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
platform: linux
|
||||
inputs:
|
||||
- name: git-repo
|
||||
outputs:
|
||||
- name: email-details
|
||||
run:
|
||||
path: git-repo/ci/scripts/determine-email-body.sh
|
||||
Loading…
Reference in New Issue