-
Notifications
You must be signed in to change notification settings - Fork 137
Support AWS CodeBuild projects #140
Comments
Just reporting back that we have a successful upload process working. Here is our version: 0.2
phases:
build:
commands:
- ...
post_build:
commands:
- VCS_PULL_REQUEST=$(echo $CODEBUILD_SOURCE_VERSION | sed 's/pr\///g')
- COV_SCRIPT=/root/.cache/codecov.sh
- if [ ! -f "$COV_SCRIPT" ]; then curl -s https://codecov.io/bash > "$COV_SCRIPT"; fi
- echo "$CODEBUILD_INITIATOR" | grep GitHub && bash "$COV_SCRIPT" -t $CODECOV_TOKEN || true
cache:
paths:
- '/root/.cache/codecov.sh' We are about to try this repo as-is and see if we can just pass the |
My team is in the process of integrating Codecov into our GitHub/CodePipeline/CodeBuild process. We've had mixed results with the proposed PR variable definition above - issue is a non-pr-branch name will result in pass-through of the name and cause the Codecov Python script to bomb because it validates that this PR value should be an integer, null, false, and maybe some other fixed value; can't recall exactly. Having noted that, it does not seem to impact anything in Codecov. PRs are still properly identified (by commit id or branch name, I expect). On the positive side, there are a one or two more environment variables which can be assigned to further integrate Codecov and CodeBuild. These are working for us. YMMV. version: 0.2
phases:
build:
commands:
- VCS_COMMIT_ID="$(git rev-parse HEAD)"
- VCS_BRANCH_NAME="$CODEBUILD_SOURCE_VERSION"
- CI_BUILD_URL=$(echo $CODEBUILD_AGENT_ENV_CODEBUILD_BUILD_URL | sed 's/#/%23/g') # Encode `#` in the URL because otherwise the url is clipped in the Codecov.io site
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
- ci_env="-e CODECOV_TOKEN=${CODECOV_TOKEN} -e VCS_COMMIT_ID=${VCS_COMMIT_ID} -e VCS_BRANCH_NAME=${VCS_BRANCH_NAME} -e CI_BUILD_URL=${CI_BUILD_URL} -e CI_BUILD_ID=${CI_BUILD_ID}"
- docker build -t project .
- docker run $ci_env project |
@gitblit Yes, we ran into the issue of non-pr's causing an issue. That's why we just threw the There have also been some improvements to this package since our initial trial, so we are able to use it instead of the codecov.sh script, still with similar env variables and parameters. |
So far, AFAICT, this However, someone from AWS acknowledged today that this is the expected value. Currently, only the CODEBUILD_WEBHOOK_TRIGGER documentation mentions pull requests, and I observed today (to my dismay!) that CODEBUILD_SOURCE_VERSION was sometimes returning commit ids for webhook-triggered PR's on GitHub. Note that CODEBUILD_WEBHOOK_TRIGGER is not an ideal replacement, as its value is not assigned on a manual rebuild. For example, if a webhook-triggered PR was rebuilt manually, the trigger variable would not be assigned during the rebuild. |
What was the last year in regard to improvements to this integration @spockNinja how did you go, any updates? |
I believe we now have several projects using this tool with no additional magic required. Here is a simplified buildspec that is working for us. version: 0.2
phases:
pre_build:
commands:
- pip install -r requirements/test.txt
build:
commands:
- pytest --cov=src/ tests
post_build:
commands:
- codecov
cache:
paths:
- '/root/.cache/pip/**/*' where we have |
Hello, thanks for the great work at CodeCov. We use it in several projects, and have recently ported from CircleCI to AWS CodeBuild (for price and AWS CodePipeline integration).
We are currently using the codecov shell script and doing some shell magic to make it all work. It would be wonderful if CodeBuild was supported "automagically" like the other CI providers.
If it helps, here is what we've done so far, and it seems to mostly be working. Once we pull the plug on Circle completely, we'll know if the uploads to master are working correctly.
VCS_PULL_REQUEST=$(echo $CODEBUILD_SOURCE_VERSION | grep pr | sed 's/pr\///g')
With that set, the git fallback seems to be handling the rest.
Here are the CodeBuild environment variables:
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
Thanks!
The text was updated successfully, but these errors were encountered: