Commit 3199ef079c0cb4fdcd2b549399c8f4d624133719
Exists in
spb-stable
and in
2 other branches
Merge branch 'deploy-key-projects' into 'master'
Deploy key in multiple projects Add doc on adding a deploy key easily to multiple projects through the API.
Showing
1 changed file
with
25 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
| 1 | +# Adding deploy keys to multiple projects | ||
| 2 | + | ||
| 3 | +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. | ||
| 4 | + | ||
| 5 | +First, find the ID of the projects you're interested in, by either listing all projects: | ||
| 6 | + | ||
| 7 | +``` | ||
| 8 | +curl --header 'PRIVATE-TOKEN: abcdef' https://gitlab.com/api/v3/projects | ||
| 9 | +``` | ||
| 10 | + | ||
| 11 | +Or finding the id of a group and then listing all projects in that group: | ||
| 12 | + | ||
| 13 | +``` | ||
| 14 | +curl --header 'PRIVATE-TOKEN: abcdef' https://gitlab.com/api/v3/groups | ||
| 15 | + | ||
| 16 | +# For group 1234: | ||
| 17 | +curl --header 'PRIVATE-TOKEN: abcdef' https://gitlab.com/api/v3/groups/1234 | ||
| 18 | +``` | ||
| 19 | + | ||
| 20 | +With those IDs, add the same deploy key to all: | ||
| 21 | +``` | ||
| 22 | +for project_id in 321 456 987; do | ||
| 23 | + curl -X POST --data '{"title": "my key", "key": "ssh-rsa AAAA..."}' --header 'PRIVATE-TOKEN: abcdef' https://gitlab.com/api/v3/projects/${project_id}/keys | ||
| 24 | +done | ||
| 25 | +``` |