how can Codebuild project extract data from Github webhook payload?

0

My impression is that webhook payload content for Codebuild projects should be accessible, having read that environmental CODEBUILD_WEBHOOK_PAYLOAD offered said content. However, I am failing to see payload inside my project with the following install phase, and "printenv" does not yield an obvious option with current EC2 (AL2) images:

  install:
    on-failure: ABORT
    runtime-versions:
      nodejs: 18
    commands:
      - echo "Webhook Payload"
      - WHPL=$(echo "${CODEBUILD_WEBHOOK_PAYLOAD}" | /usr/bin/jq '.')
      - echo "${WHPL}"
      - echo "INSTALL PHASE COMPLETE"

I would like to extract custom content from the payload for customized build metadata ... all suggestions are welcome!

asked 4 months ago262 views
1 Answer
0

Hello,

Firstly I would like to mention that the variable “CODEBUILD_WEBHOOK_PAYLOAD” mentioned in the shared buildspec is not supported by Code Build Service. The Service supports the below WebHooks related environment variables that can be used in build commands.

CODEBUILD_WEBHOOK_ACTOR_ACCOUNT_ID
CODEBUILD_WEBHOOK_BASE_REF 
CODEBUILD_WEBHOOK_EVENT
CODEBUILD_WEBHOOK_MERGE_COMMIT 
CODEBUILD_WEBHOOK_PREV_COMMIT
CODEBUILD_WEBHOOK_HEAD_REF
CODEBUILD_WEBHOOK_TRIGGER

Please refer AWS Document [1] for more details.

Please note that currently AWS Code Build Service does not support storing the webhook payload, thus the full payload can also not be used for the service. Currently, we also have an open internal feature request with our AWS Code Build Internal team and they are are working towards it.

As the development process goes through multiple stages of planning, coding and rigorous testing before a feature is released, thus we do not have an ETA as to when this feature may be released.

I encourage you to stay updated on the latest AWS services and feature updates by regularly visiting https://repost.aws/, https://aws.amazon.com/new/ and https://aws.amazon.com/blogs/.

If you have any further technical support questions requiring additional assistance, please feel free to reach out by opening a support case.

Thank you.


Reference
[1] Environment variables in build environments - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

AWS
answered 4 months ago
profile picture
EXPERT
reviewed 18 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions