Chuyển tới nội dung chính

Create source

POST/api/projects/{projectId}/sources
Quản trị viên

Đọc thêm: Kết nối một nguồnMã nguồn: ProjectApiController#createSource(mở trong thẻ mới)

Tham số đường dẫn​

TênKiểuBắt buộcGhi chú
projectIdstring (uuid)Bắt buộc

Request body​

application/json

TrườngKiểuBắt buộcGhi chú
typeenum SourceTypeTùy chọnGITHUBGITLABLINEARJIRA
ownerstringTùy chọn
repositorystringTùy chọn
projectPathstringTùy chọn
apiBaseUrlstringTùy chọn
webhookAuthModeenum WebhookAuthModeTùy chọnGITHUB_HMACGITLAB_SIGNING_TOKENGITLAB_SECRET_TOKENLINEAR_HMACNONE
teamIdstringTùy chọn
webhookSecretstringTùy chọn
apiTokenstringTùy chọn
projectKeystringTùy chọn
siteUrlstringTùy chọn
accountEmailstringTùy chọn

Response​

Thành công: 201

TrườngKiểuBắt buộcGhi chú
idstring (uuid)Tùy chọn
projectIdstring (uuid)Tùy chọn
typeenum SourceTypeTùy chọnGITHUBGITLABLINEARJIRA
externalProjectKeystringTùy chọn
externalTeamKeystringTùy chọn
ownerstringTùy chọn
repositorystringTùy chọn
apiBaseUrlstringTùy chọn
externalWorkspaceKeystringTùy chọn
credentialIdentitystringTùy chọn
webhookAuthModeenum WebhookAuthModeTùy chọnGITHUB_HMACGITLAB_SIGNING_TOKENGITLAB_SECRET_TOKENLINEAR_HMACNONE
webhookIdstring (uuid)Tùy chọn
webhookPathstringTùy chọn
webhookSecretstringTùy chọn
createdAtstring (date-time)Tùy chọn

Lỗi​

Trạng tháiMãÁp dụng cho
400validation_failedthiếu trường hoặc giá trị nằm ngoài khoảng cho phépMọi endpoint
400malformed_requestkhông đọc được bodyMọi endpoint
400invalid_parametermột tham số trên đường dẫn hoặc query bị thiếu hoặc không chuyển đổi được, chẳng hạn một ID không phải UUIDMọi endpoint
401authentication_requiredchưa có phiên đăng nhậpMọi endpoint
403access_deniedendpoint dành cho quản trị viên, hoặc CSRF token thiếu hay đã cũMọi endpoint
404not_foundkhông có địa chỉ đóMọi endpoint
405method_not_allowedđịa chỉ không nhận phương thức đóMọi endpoint
415unsupported_media_typeđịa chỉ không đọc body thuộc kiểu đóMọi endpoint
500internal_errormột lỗi ReleaseFlow không lường trước; body không bao giờ chứa exception gây ra nóMọi endpoint
400gitlab_base_url_invalidKhu vực Sources
400gitlab_host_not_allowedKhu vực Sources
400jira_site_invalidKhu vực Sources
400github_token_rejectedKhu vực Sources
400gitlab_token_rejectedKhu vực Sources
400linear_token_rejectedKhu vực Sources
400jira_token_rejectedKhu vực Sources
400source_credential_requiredKhu vực Sources
400source_signing_token_invalidKhu vực Sources
404project_not_foundKhu vực Sources
404source_not_foundKhu vực Sources
409github_repository_already_connectedKhu vực Sources
409gitlab_project_already_connectedKhu vực Sources
409linear_team_already_connectedKhu vực Sources
409jira_project_already_connectedKhu vực Sources
409source_token_missingKhu vực Sources
409source_sync_in_progressKhu vực Sources
409source_import_not_supportedKhu vực Sources
409source_import_not_resumableKhu vực Sources
409source_disconnectedKhu vực Sources
409source_not_disconnectedKhu vực Sources
409source_reconnect_requiredKhu vực Sources
409source_has_no_webhookKhu vực Sources
409source_secret_generatedKhu vực Sources
409source_secret_pastedKhu vực Sources
503github_unavailableKhu vực Sources
503gitlab_unavailableKhu vực Sources
503jira_unavailableKhu vực Sources

Request

bash
# Sign in first and keep the session cookie in cookies.txt (see Sessions and CSRF).
# CSRF_HEADER and CSRF_TOKEN are the headerName and token GET /api/csrf returned.
curl -X POST "http://localhost:8080/api/projects/$PROJECT_ID/sources" \
-b cookies.txt -c cookies.txt \
-H "$CSRF_HEADER: $CSRF_TOKEN" \
-H "Content-Type: application/json" \
--data '{
"type": "GITHUB",
"owner": "<string>",
"repository": "<string>",
"projectPath": "<string>",
"apiBaseUrl": "<string>",
"webhookAuthMode": "GITHUB_HMAC",
"teamId": "<string>",
"webhookSecret": "<string>",
"apiToken": "<string>",
"projectKey": "<string>",
"siteUrl": "<string>",
"accountEmail": "<string>"
}'

Request body là ví dụ dựng từ schema; thay mọi giá trị giữ chỗ trước khi gửi.

Response

201

Ví dụ

{
  "id": "<uuid>",
  "projectId": "<uuid>",
  "type": "GITHUB",
  "externalProjectKey": "<string>",
  "externalTeamKey": "<string>",
  "owner": "<string>",
  "repository": "<string>",
  "apiBaseUrl": "<string>",
  "externalWorkspaceKey": "<string>",
  "credentialIdentity": "<string>",
  "webhookAuthMode": "GITHUB_HMAC",
  "webhookId": "<uuid>",
  "webhookPath": "<string>",
  "webhookSecret": "<string>",
  "createdAt": "<date-time>"
}