/AWS1/IF_BLD=>CREATEWEBHOOK()¶
About CreateWebhook¶
For an existing CodeBuild build project that has its source code stored in a GitHub or Bitbucket repository, enables CodeBuild to start rebuilding the source code every time a code change is pushed to the repository.
If you enable webhooks for an CodeBuild project, and the project is used as a build step in CodePipeline, then two identical builds are created for each commit. One build is triggered through webhooks, and one through CodePipeline. Because billing is on a per-build basis, you are billed for both builds. Therefore, if you are using CodePipeline, we recommend that you disable webhooks in CodeBuild. In the CodeBuild console, clear the Webhook box. For more information, see step 5 in Change a Build Project's Settings.
Method Signature¶
METHODS /AWS1/IF_BLD~CREATEWEBHOOK
IMPORTING
!IV_PROJECTNAME TYPE /AWS1/BLDPROJECTNAME OPTIONAL
!IV_BRANCHFILTER TYPE /AWS1/BLDSTRING OPTIONAL
!IT_FILTERGROUPS TYPE /AWS1/CL_BLDWEBHOOKFILTER=>TT_FILTERGROUPS OPTIONAL
!IV_BUILDTYPE TYPE /AWS1/BLDWEBHOOKBUILDTYPE OPTIONAL
!IV_MANUALCREATION TYPE /AWS1/BLDWRAPPERBOOLEAN OPTIONAL
!IO_SCOPECONFIGURATION TYPE REF TO /AWS1/CL_BLDSCOPECONFIGURATION OPTIONAL
!IO_PULLREQUESTBUILDPOLICY TYPE REF TO /AWS1/CL_BLDPULLREQBUILDPOLICY OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_bldcreatewebhookout
RAISING
/AWS1/CX_BLDINVALIDINPUTEX
/AWS1/CX_BLDOAUTHPROVIDEREX
/AWS1/CX_BLDRESRCALRDYEXISTSEX
/AWS1/CX_BLDRESOURCENOTFOUNDEX
/AWS1/CX_BLDCLIENTEXC
/AWS1/CX_BLDSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_projectname TYPE /AWS1/BLDPROJECTNAME /AWS1/BLDPROJECTNAME¶
The name of the CodeBuild project.
Optional arguments:¶
iv_branchfilter TYPE /AWS1/BLDSTRING /AWS1/BLDSTRING¶
A regular expression used to determine which repository branches are built when a webhook is triggered. If the name of a branch matches the regular expression, then it is built. If
branchFilteris empty, then all branches are built.It is recommended that you use
filterGroupsinstead ofbranchFilter.
it_filtergroups TYPE /AWS1/CL_BLDWEBHOOKFILTER=>TT_FILTERGROUPS TT_FILTERGROUPS¶
An array of arrays of
WebhookFilterobjects used to determine which webhooks are triggered. At least oneWebhookFilterin the array must specifyEVENTas itstype.For a build to be triggered, at least one filter group in the
filterGroupsarray must pass. For a filter group to pass, each of its filters must pass.
iv_buildtype TYPE /AWS1/BLDWEBHOOKBUILDTYPE /AWS1/BLDWEBHOOKBUILDTYPE¶
Specifies the type of build this webhook will trigger.
RUNNER_BUILDKITE_BUILDis only available forNO_SOURCEsource type projects configured for Buildkite runner builds. For more information about CodeBuild-hosted Buildkite runner builds, see Tutorial: Configure a CodeBuild-hosted Buildkite runner in the CodeBuild user guide.
iv_manualcreation TYPE /AWS1/BLDWRAPPERBOOLEAN /AWS1/BLDWRAPPERBOOLEAN¶
If manualCreation is true, CodeBuild doesn't create a webhook in GitHub and instead returns
payloadUrlandsecretvalues for the webhook. ThepayloadUrlandsecretvalues in the output can be used to manually create a webhook within GitHub.
manualCreationis only available for GitHub webhooks.
io_scopeconfiguration TYPE REF TO /AWS1/CL_BLDSCOPECONFIGURATION /AWS1/CL_BLDSCOPECONFIGURATION¶
The scope configuration for global or organization webhooks.
Global or organization webhooks are only available for GitHub and Github Enterprise webhooks.
io_pullrequestbuildpolicy TYPE REF TO /AWS1/CL_BLDPULLREQBUILDPOLICY /AWS1/CL_BLDPULLREQBUILDPOLICY¶
A PullRequestBuildPolicy object that defines comment-based approval requirements for triggering builds on pull requests. This policy helps control when automated builds are executed based on contributor permissions and approval workflows.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_bldcreatewebhookout /AWS1/CL_BLDCREATEWEBHOOKOUT¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->createwebhook(
io_pullrequestbuildpolicy = new /aws1/cl_bldpullreqbuildpolicy(
it_approverroles = VALUE /aws1/cl_bldpullreqbldapprro00=>tt_pullreqbuildapproverroles(
( new /aws1/cl_bldpullreqbldapprro00( |string| ) )
)
iv_requirescommentapproval = |string|
)
io_scopeconfiguration = new /aws1/cl_bldscopeconfiguration(
iv_domain = |string|
iv_name = |string|
iv_scope = |string|
)
it_filtergroups = VALUE /aws1/cl_bldwebhookfilter=>tt_filtergroups(
(
VALUE /aws1/cl_bldwebhookfilter=>tt_filtergroup(
(
new /aws1/cl_bldwebhookfilter(
iv_excludematchedpattern = ABAP_TRUE
iv_pattern = |string|
iv_type = |string|
)
)
)
)
)
iv_branchfilter = |string|
iv_buildtype = |string|
iv_manualcreation = ABAP_TRUE
iv_projectname = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lo_webhook = lo_result->get_webhook( ).
IF lo_webhook IS NOT INITIAL.
lv_nonemptystring = lo_webhook->get_url( ).
lv_nonemptystring = lo_webhook->get_payloadurl( ).
lv_nonemptystring = lo_webhook->get_secret( ).
lv_string = lo_webhook->get_branchfilter( ).
LOOP AT lo_webhook->get_filtergroups( ) into lt_row.
LOOP AT lt_row into lo_row_1.
lo_row_2 = lo_row_1.
IF lo_row_2 IS NOT INITIAL.
lv_webhookfiltertype = lo_row_2->get_type( ).
lv_string = lo_row_2->get_pattern( ).
lv_wrapperboolean = lo_row_2->get_excludematchedpattern( ).
ENDIF.
ENDLOOP.
ENDLOOP.
lv_webhookbuildtype = lo_webhook->get_buildtype( ).
lv_wrapperboolean = lo_webhook->get_manualcreation( ).
lv_timestamp = lo_webhook->get_lastmodifiedsecret( ).
lo_scopeconfiguration = lo_webhook->get_scopeconfiguration( ).
IF lo_scopeconfiguration IS NOT INITIAL.
lv_string = lo_scopeconfiguration->get_name( ).
lv_string = lo_scopeconfiguration->get_domain( ).
lv_webhookscopetype = lo_scopeconfiguration->get_scope( ).
ENDIF.
lv_webhookstatus = lo_webhook->get_status( ).
lv_string = lo_webhook->get_statusmessage( ).
lo_pullrequestbuildpolicy = lo_webhook->get_pullrequestbuildpolicy( ).
IF lo_pullrequestbuildpolicy IS NOT INITIAL.
lv_pullrequestbuildcomment = lo_pullrequestbuildpolicy->get_requirescommentapproval( ).
LOOP AT lo_pullrequestbuildpolicy->get_approverroles( ) into lo_row_3.
lo_row_4 = lo_row_3.
IF lo_row_4 IS NOT INITIAL.
lv_pullrequestbuildapprove = lo_row_4->get_value( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.