I have set up a script for local builds as described in the 2.0 docs here:
I have pasted in the script below. Unfortunately the JSON returned does not include all the the error messages that are available in the CircleCI UI.
Here are two errors I was getting in the UI but only the 2nd error was reported in the returned JSON:
- Error parsing config file: yaml: line 8: mapping values are not allowed in this context
- Cannot find a job named
build
to run in thejobs:
section of your configuration file.
I assume this is an oversight?
#!/usr/bin/env bash
CIRCLE_TOKEN="$(cat local.token)"
LATEST_COMMIT="$(git log -1 --pretty=format:"%H")"
REPO_REF="$(git remote v | grep push | awk '{print $2}' | sed 's/git\@//' | sed 's/:/\//' | sed 's/\.git//' | sed 's/\.com//')"
BRANCH_NAME="$(git branch | grep '*' | awk '{print $2}')"
curl \
--silent \
--user "${CIRCLE_TOKEN}": \
--request POST \
--form revision="${LATEST_COMMIT}" \
--form config=@config.yml \
--remote-name \
--form notify=false \
"https://circleci.com/api/v1.1/project/${REPO_REF}/tree/${BRANCH_NAME}"
rm LAST_LOCAL_BUILD.json
mv "${BRANCH_NAME}" LAST_LOCAL_BUILD.json
echo
cat LAST_LOCAL_BUILD.json | jq -r '.messages[].message' | sed -e 's/<[a-zA-Z\/][^>]*>//g'