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!

已提问 5 个月前300 查看次数
1 回答
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
已回答 5 个月前
profile picture
专家
已审核 1 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则