In a few of my codepipelines, I have set up E2E testing with cypress/mocha/mochawesome-reporter to run tests in the post-build section of my codebuild. Then, I added a --recursive line (see below) to take all the report materials out of the build and move them into a timestamped (see : "$(date +"%Y%m%d-%H%M")") directory in an s3 bucket. I wanted to know if there is a way to access the last commit message (perhaps as an environmental variable or otherwise?) and add that to the name of my timestamped directory. I have read through a lot of the documentation but only see environmental variables which allow you to pull out git ID/Hash.
I know you can see the last commit message in the "Source" portion of your codepipeline (via webhooks), so maybe there is a way to propagate that information through to the build section?
Further info : The codepipelines are triggered by webhooks seeing a new push to my repo.
Have read documentation. Tried adding "printenv" in the codebuild, and then when I watched the tail logs come in, I didn't see any commit messages I could pull out.
post_build:
commands:
- npm run ci
- aws s3 mv mochawesome-report s3://XXX-BUCKET/reports/XXX-PRODUCT/$(date +"%Y%m%d-%H%M") --recursive
I expect there might be some possible way to pull the last git commit message out, maybe that last line in my code examples would look like :
- aws s3 mv mochawesome-report s3://XXX-BUCKET/reports/XXX-PRODUCT/$(date +"%Y%m%d-%H%M")CODEBUILD_SRC_GIT_COMMIT_MSG?? --recursive