일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- protobuf-c
- C/C++
- 기념일관리
- 블루투스 헤드셋
- GDI
- phpmailer
- 설치제거
- JavaScript
- 한 번만 실행
- 자바스크립트
- 와이브로
- M8200
- crashlog
- PDA
- VS2008
- net
- .net
- Font
- 데이터 전달
- Antialiasing
- 크래시로그
- self-signed ssl
- ClickOnce
- API
- MFC
- plcrashreporter
- php
- docker
- C#
- EUC-KR
- Today
- Total
~☆~ 우하하!!~ 개발블로그
gitlab API 본문
owner 가 생성한 프로젝트 sample(id:3)
Group GitLab Instance
User woohaha는 GitLab Instance Group 에 Developer 권한으로 추가되어 있음.
User woohaha 의 User Token 이 발급되어 있는 상태
Project Sample 의 Repository: Protected branches 설정에서 Allowed to merge, Allowed to push and merge 권한자로 Developer 를 포함
# create new branch
curl --request POST --header "PRIVATE-TOKEN:glpat-2mHXLn7j52uH71yubH78" "http://192.168.0.72/api/v4/projects/3/repository/branches?branch=newnewbranch&ref=main"
glpat-2mHXLn7j52uH71yubH78 : User's Token
http://192.168.0.72/ : gitlab url
3 : project id
newnewbranch : 생성할 브랜치명
main : 기반 브랜치명
result:
{
"name": "newnewbranch",
"commit": {
"id": "63638428c7819787db764e68628c460c1433d6ce",
"short_id": "63638428",
"created_at": "2023-04-12T23:55:37.000+00:00",
"parent_ids": [],
"title": "Initial commit",
"message": "Initial commit",
"author_name": "Administrator",
"author_email": "admin@example.com",
"authored_date": "2023-04-12T23:55:37.000+00:00",
"committer_name": "Administrator",
"committer_email": "admin@example.com",
"committed_date": "2023-04-12T23:55:37.000+00:00",
"trailers": {},
"web_url": "http://192.168.0.72/gitlab-instance-73484526/mysampledotnet/-/commit/63638428c7819787db764e68628c460c1433d6ce"
},
"merged": false,
"protected": false,
"developers_can_push": false,
"developers_can_merge": false,
"can_push": true,
"default": false,
"web_url": "http://192.168.0.72/gitlab-instance-73484526/mysampledotnet/-/tree/newnewbranch"
}
# commit a new file creating
PAYLOAD=$(cat << 'JSON'
{
"branch": "woohaha-working",
"start_branch": "main",
"commit_message": "some commit message",
"actions": [
{
"action": "create",
"file_path": "newfile.txt", // repository 에 생성할 파일명
"content": "newfile contents" // 생성할 파일의 내용
}
]
}
JSON
)
curl --request POST --header "PRIVATE-TOKEN:glpat-2mHXLn7j52uH71yubH78" --header "Content-Type: application/json" --data "$PAYLOAD" "http://192.168.0.72/api/v4/projects/3/repository/commits"
result:
{
"id": "594cd2495fcc8faa3b9d4d03089f85a201e0af69",
"short_id": "594cd249",
"created_at": "2023-04-13T05:01:55.000+00:00",
"parent_ids": [
"63638428c7819787db764e68628c460c1433d6ce"
],
"title": "some commit message",
"message": "some commit message",
"author_name": "woohaha",
"author_email": "woohaha.apps@gmail.com",
"authored_date": "2023-04-13T05:01:55.000+00:00",
"committer_name": "woohaha",
"committer_email": "woohaha.apps@gmail.com",
"committed_date": "2023-04-13T05:01:55.000+00:00",
"trailers": {},
"web_url": "http://192.168.0.72/gitlab-instance-73484526/mysampledotnet/-/commit/594cd2495fcc8faa3b9d4d03089f85a201e0af69",
"stats": {
"additions": 1,
"deletions": 0,
"total": 1
},
"status": null,
"project_id": 3,
"last_pipeline": null
}
# commit a existing local file
https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
curl --request POST \
--form "branch=woohaha-working" \
--form "commit_message=test_push_file_from_api" \
--form "actions[][action]=update" \ // create | update | delete | move
--form "actions[][file_path]=data.yaml" \
--form "actions[][content]=<d:\\_MyProject\\Sample\\mysampledotnet\\data.yaml" \ // full path of file
--header "PRIVATE-TOKEN:glpat-2mHXLn7j52uH71yubH78" \
"http://192.168.0.72/api/v4/projects/3/repository/commits"
# create Merge Request
https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
curl --request POST --header "PRIVATE-TOKEN:glpat-ctMZnB3pzkxQ1q71xVD2" "http://192.168.0.72/api/v4/projects/3/merge_requests?source_branch=woohaha-working&target_branch=main&title=testmerge"
# list all projects
curl --header "PRIVATE-TOKEN:glpat-2mHXLn7j52uH71yubH78" "http://192.168.0.72/api/v4/projects"
# search project
curl --header "PRIVATE-TOKEN:glpat-2mHXLn7j52uH71yubH78" "http://192.168.0.72/api/v4/projects?search=campus"
result:
[
{
"id": 2,
"description": null,
"name": "meta-campus",
"name_with_namespace": "GitLab Instance / meta-campus",
"path": "meta-campus",
"path_with_namespace": "gitlab-instance-73484526/meta-campus",
"created_at": "2023-04-12T01:23:38.628Z",
"default_branch": "main",
"tag_list": [],
"topics": [],
"ssh_url_to_repo": "git@192.168.0.72:gitlab-instance-73484526/meta-campus.git",
"http_url_to_repo": "http://192.168.0.72/gitlab-instance-73484526/meta-campus.git",
"web_url": "http://192.168.0.72/gitlab-instance-73484526/meta-campus",
"readme_url": "http://192.168.0.72/gitlab-instance-73484526/meta-campus/-/blob/main/README.md",
"forks_count": 0,
"avatar_url": null,
"star_count": 0,
"last_activity_at": "2023-04-12T01:23:38.628Z",
"namespace": {
"id": 2,
"name": "GitLab Instance",
"path": "gitlab-instance-73484526",
"kind": "group",
"full_path": "gitlab-instance-73484526",
"parent_id": null,
"avatar_url": null,
"web_url": "http://192.168.0.72/groups/gitlab-instance-73484526"
},
"_links": {
"self": "http://192.168.0.72/api/v4/projects/2",
"issues": "http://192.168.0.72/api/v4/projects/2/issues",
"merge_requests": "http://192.168.0.72/api/v4/projects/2/merge_requests",
"repo_branches": "http://192.168.0.72/api/v4/projects/2/repository/branches",
"labels": "http://192.168.0.72/api/v4/projects/2/labels",
"events": "http://192.168.0.72/api/v4/projects/2/events",
"members": "http://192.168.0.72/api/v4/projects/2/members",
"cluster_agents": "http://192.168.0.72/api/v4/projects/2/cluster_agents"
},
"packages_enabled": true,
"empty_repo": false,
"archived": false,
"visibility": "internal",
"resolve_outdated_diff_discussions": false,
"container_expiration_policy": {
"cadence": "1d",
"enabled": false,
"keep_n": 10,
"older_than": "90d",
"name_regex": ".*",
"name_regex_keep": null,
"next_run_at": "2023-04-13T01:23:38.738Z"
},
"issues_enabled": true,
"merge_requests_enabled": true,
"wiki_enabled": true,
"jobs_enabled": true,
"snippets_enabled": true,
"container_registry_enabled": true,
"service_desk_enabled": false,
"service_desk_address": null,
"can_create_merge_request_in": true,
"issues_access_level": "enabled",
"repository_access_level": "enabled",
"merge_requests_access_level": "enabled",
"forking_access_level": "enabled",
"wiki_access_level": "enabled",
"builds_access_level": "enabled",
"snippets_access_level": "enabled",
"pages_access_level": "enabled",
"operations_access_level": "enabled",
"analytics_access_level": "enabled",
"container_registry_access_level": "enabled",
"security_and_compliance_access_level": "private",
"releases_access_level": "enabled",
"environments_access_level": "enabled",
"feature_flags_access_level": "enabled",
"infrastructure_access_level": "enabled",
"monitor_access_level": "enabled",
"emails_disabled": null,
"shared_runners_enabled": true,
"group_runners_enabled": true,
"lfs_enabled": true,
"creator_id": 1,
"import_status": "none",
"open_issues_count": 0,
"ci_default_git_depth": 20,
"ci_forward_deployment_enabled": true,
"ci_job_token_scope_enabled": false,
"ci_separated_caches": true,
"ci_opt_in_jwt": false,
"ci_allow_fork_pipelines_to_run_in_parent_project": true,
"public_jobs": true,
"build_timeout": 3600,
"auto_cancel_pending_pipelines": "enabled",
"ci_config_path": null,
"shared_with_groups": [],
"only_allow_merge_if_pipeline_succeeds": false,
"allow_merge_on_skipped_pipeline": null,
"restrict_user_defined_variables": false,
"request_access_enabled": true,
"only_allow_merge_if_all_discussions_are_resolved": false,
"remove_source_branch_after_merge": true,
"printing_merge_request_link_enabled": true,
"merge_method": "merge",
"squash_option": "default_off",
"enforce_auth_checks_on_uploads": true,
"suggestion_commit_message": null,
"merge_commit_template": null,
"squash_commit_template": null,
"issue_branch_template": null,
"auto_devops_enabled": true,
"auto_devops_deploy_strategy": "continuous",
"autoclose_referenced_issues": true,
"keep_latest_artifact": true,
"runner_token_expiration_interval": null,
"permissions": {
"project_access": null,
"group_access": {
"access_level": 30,
"notification_level": 3
}
}
}
]