Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
609baf6f
Commit
609baf6f
authored
Jan 18, 2016
by
Achilleas Pipinellis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor deploy_key_multiple_projects API documentation [ci skip]
parent
835f1961
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
doc/api/deploy_key_multiple_projects.md
doc/api/deploy_key_multiple_projects.md
+11
-7
No files found.
doc/api/deploy_key_multiple_projects.md
View file @
609baf6f
# Adding deploy keys to multiple projects
If you want to easily add the same deploy key to multiple projects in the same group, this can be achieved quite easily with the API.
If you want to easily add the same deploy key to multiple projects in the same
group, this can be achieved quite easily with the API.
First, find the ID of the projects you're interested in, by either listing all projects:
First, find the ID of the projects you're interested in, by either listing all
projects:
```
curl -
-header 'PRIVATE-TOKEN: abcdef' https://gitlab
.com/api/v3/projects
curl -
H 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' https://gitlab.example
.com/api/v3/projects
```
Or finding the
id
of a group and then listing all projects in that group:
Or finding the
ID
of a group and then listing all projects in that group:
```
curl -
-header 'PRIVATE-TOKEN: abcdef' https://gitlab
.com/api/v3/groups
curl -
H 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' https://gitlab.example
.com/api/v3/groups
# For group 1234:
curl -
-header 'PRIVATE-TOKEN: abcdef' https://gitlab
.com/api/v3/groups/1234
curl -
H 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' https://gitlab.example
.com/api/v3/groups/1234
```
With those IDs, add the same deploy key to all:
```
for project_id in 321 456 987; do
curl -X POST --data '{"title": "my key", "key": "ssh-rsa AAAA..."}' --header 'PRIVATE-TOKEN: abcdef' https://gitlab.com/api/v3/projects/${project_id}/keys
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" -H "Content-Type: application/json" \
--data '{"title": "my key", "key": "ssh-rsa AAAA..."}' https://gitlab.example.com/api/v3/projects/${project_id}/keys
done
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment