I’ve been trying to get Slack integration going on our builds and ran into something that definitely feels like a bug. If you stick a pre-steps
section into your aws-ecr/build-and-push-image
job and try to send a slack notification (alerting users that the build has started), the build will fail in the checkout
section with this error:
Directory (/home/circleci/project) you are trying to checkout to is not empty and not a git repository
Removing (or commenting out) the slack notify lets the job complete. A success/fail notification in post-steps
does work.
Here is a partial snippet of my config.yml showing what I’m trying:
- aws-ecr/build-and-push-image:
executor: ubuntu-small
setup-remote-docker: true
dockerfile: docker-build/Dockerfile
context: aws-dev-context
repo: builds
tag: ${CIRCLE_BRANCH}_${CIRCLE_BUILD_NUM}
create-repo: true
pre-steps:
- run:
command: |
echo "TICKET=`expr match \"${CIRCLE_BRANCH}\" '\(XYZ-[0-9]*\)'`" >> $BASH_ENV
source $BASH_ENV
- slack/notify:
event: always
custom: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Branch build* #${CIRCLE_BUILD_NUM} started for ${CIRCLE_BRANCH}. <https://xyz.atlassian.net/browse/${TICKET}|${TICKET}>"
}
},
{
"type": "divider"
}
]
}
post-steps:
- slack/notify:
event: pass
template: basic_success_1
- slack/notify:
event: fail
template: basic_fail_1