mirror of https://github.com/zulip/zulip.git
circleci: Support the "ping" event type.
This commit is contained in:
parent
27878cce87
commit
d30ab34e3d
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"happened_at": "2023-06-17T19:50:27.457981Z",
|
||||
"id": "d1264809-3541-48db-9d72-68f04f074877",
|
||||
"type": "ping",
|
||||
"webhook": {
|
||||
"id": "87f2e824-39f9-4fa8-985e-ce1a0571ad93",
|
||||
"name": "Testing"
|
||||
}
|
||||
}
|
|
@ -6,6 +6,11 @@ class CircleCiHookTests(WebhookTestCase):
|
|||
URL_TEMPLATE = "/api/v1/external/circleci?stream={stream}&api_key={api_key}"
|
||||
WEBHOOK_DIR_NAME = "circleci"
|
||||
|
||||
def test_ping(self) -> None:
|
||||
expected_topic = "Test event"
|
||||
expected_message = "Webhook 'Testing' test event successful."
|
||||
self.check_webhook("ping", expected_topic, expected_message)
|
||||
|
||||
def test_bitbucket_job_completed(self) -> None:
|
||||
expected_topic = "circleci-webhook-testing"
|
||||
expected_message = """
|
||||
|
|
|
@ -54,7 +54,7 @@ Job `{job_name}` within Pipeline #{pipeline_number} {formatted_status}.
|
|||
{commit_details}
|
||||
"""
|
||||
|
||||
ALL_EVENT_TYPES = ["job-completed", "workflow-completed"]
|
||||
ALL_EVENT_TYPES = ["ping", "job-completed", "workflow-completed"]
|
||||
|
||||
|
||||
@webhook_view("CircleCI", all_event_types=ALL_EVENT_TYPES)
|
||||
|
@ -64,17 +64,24 @@ def api_circleci_webhook(
|
|||
user_profile: UserProfile,
|
||||
payload: WildValue = REQ(argument_type="body", converter=to_wild_value),
|
||||
) -> HttpResponse:
|
||||
subject = get_subject(payload)
|
||||
body = get_body(payload)
|
||||
type = payload["type"].tame(check_string)
|
||||
if type == "ping":
|
||||
# Ping events don't have full payloads, so our normal codepath won't work
|
||||
subject = "Test event"
|
||||
body = "Webhook '{name}' test event successful.".format(
|
||||
name=payload["webhook"]["name"].tame(check_string)
|
||||
)
|
||||
else:
|
||||
subject = get_subject(payload)
|
||||
body = get_body(payload)
|
||||
|
||||
pipeline = payload["pipeline"]
|
||||
|
||||
# We currently don't support projects using VCS providers other than GitHub,
|
||||
# BitBucket and GitLab.
|
||||
if "trigger_parameters" in pipeline and pipeline["trigger"]["type"] != "gitlab":
|
||||
raise JsonableError(
|
||||
_("Projects using this version control system provider aren't supported")
|
||||
) # nocoverage
|
||||
# We currently don't support projects using VCS providers other than GitHub,
|
||||
# BitBucket and GitLab.
|
||||
pipeline = payload["pipeline"]
|
||||
if "trigger_parameters" in pipeline and pipeline["trigger"]["type"] != "gitlab":
|
||||
raise JsonableError(
|
||||
_("Projects using this version control system provider aren't supported")
|
||||
) # nocoverage
|
||||
|
||||
check_send_webhook_message(
|
||||
request,
|
||||
|
|
Loading…
Reference in New Issue