2

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
1

1 Answer 1

1

The script https://github.com/thii/aws-codebuild-extras provides additional environment variables in CodeBuild, including one for CODEBUILD_GIT_MESSAGE. Maybe something similar would work in CodePipeline?

Sign up to request clarification or add additional context in comments.

1 Comment

It returns fatal: No tags can describe 'bf27############'. Try --always, or create some tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.