jenkinsci / jenkinsci/gitlab-branch-source-plugin
[JENKINS-59548] Automatically enable "Deploy Key" for Gitlab project
- Dominant language
- Java
- Stars
- 134
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
To enable Jenkins to checkout our Git projects from Gitlab, the "Deploy Key" of Jenkins currently must be enabled for each project in Gitlab individually.This is a tedious task that can be automated using the Gitlab API.
A practical example:
- In Gitlab, go to "Admin Area" -> "Deploy Keys" and add a new key that we will call "jenkins-gitlab".
- To enable Jenkins to checkout the source code of the project named "MyProject", we must enable the deploy key for this project in Gitlab. For this, I currently have to go to the Settings of the gitlab project "MyProject" manually ("Settings" -> "Repository" -> "Deploy Keys") to enable the Deploy Key called "jenkins-gitlab").
Using the gitlab-branch-source-plugin, this is the only thing I currently still have to do manually for each new gitlab project.
Fortunately, this could be automated using the Gitlab API. Please have a look at the section "Enable a deploy key": https://docs.gitlab.com/ce/api/deploy_keys.html#enable-a-deploy-key
If would be really great if I could configure the "Deploy Key" to use at organization-folder level in Gitlab (or maybe even as a system setting) that "gitlab-branch-source-plugin" uses to automatically call the Gitlab API to enable the deploy config for the gitlab projects. I think this should be offered as a trait that shows a combobox of available Deploy Keys. To fill the combox of available Deploy Keys, you can use this API: https://docs.gitlab.com/ce/api/deploy_keys.html#list-all-deploy-keys
---
Originally reported by christianciach, imported from: Automatically enable "Deploy Key" for Gitlab project
Raw content of original issue
To enable Jenkins to checkout our Git projects from Gitlab, the "Deploy Key" of Jenkins currently must be enabled for each project in Gitlab individually.This is a tedious task that can be automated using the Gitlab API.
A practical example:
- In Gitlab, go to "Admin Area" -> "Deploy Keys" and add a new key that we will call "jenkins-gitlab".
- To enable Jenkins to checkout the source code of the project named "MyProject", we must enable the deploy key for this project in Gitlab. For this, I currently have to go to the Settings of the gitlab project "MyProject" manually ("Settings" -> "Repository" -> "Deploy Keys") to enable the Deploy Key called "jenkins-gitlab").
Using the gitlab-branch-source-plugin, this is the only thing I currently still have to do manually for each new gitlab project.
Fortunately, this could be automated using the Gitlab API. Please have a look at the section "Enable a deploy key": https://docs.gitlab.com/ce/api/deploy_keys.html#enable-a-deploy-key
If would be really great if I could configure the "Deploy Key" to use at organization-folder level in Gitlab (or maybe even as a system setting) that "gitlab-branch-source-plugin" uses to automatically call the Gitlab API to enable the deploy config for the gitlab projects. I think this should be offered as a trait that shows a combobox of available Deploy Keys. To fill the combox of available Deploy Keys, you can use this API: https://docs.gitlab.com/ce/api/deploy_keys.html#list-all-deploy-keys
Contributor guide
Assessment
This issue has not been assessed yet.