Implement API/GraphQL endpoint for "Require an associated issue from Jira"
Release notes
The project merge request setting "Require an associated issue from Jira" can now be configured via GitLab API or GraphQL queries. This was previously only available as a checkbox setting in the UI.
Problem to solve
A Mid-Market SaaS Customer expressed interest in this ticket to have the ability to use code/scripting to toggle this setting, as it is currently only available via the UI. The customer would like to enable this on all projects they have on GitLab.com, but currently has to do so manually.
Proposal
We expand the current method (prevent_merge_without_jira_issue
) to have an accessible API attribute under Project Settings API. For example:
curl --request PUT --header "PRIVATE-TOKEN: <token>" --url "http://gitlab.example.com/api/v4/projects/<id>" --data "prevent_merge_without_jira_issue=true"
Workaround for Self-Managed Users
Self-Managed Users can use a Rails console to enable this for a singular project, or all projects:
Example 1, change x
to the project's ID.
p = Project.find_by(id: x)
p.project_setting.prevent_merge_without_jira_issue = true
p.save!
Example 2, all projects on the instance:
Project.find_each do |p|
puts p.id
p.project_setting.prevent_merge_without_jira_issue = true
p.save!
end