gitlabgitlab-apigitlab-omnibus

Gitlab. How to configure instance level integrations without WebUI


My standalone Gitlab has an option for integrating Jira. Gitlab Web UI shows Jira in the list of available integrations under Admin Area > Instance-level integration management.

I would like to enable and configure Jira integration for my newly deployed instance using the gitlab-rails console or REST API, without the WebUI. How can I do this?

Gitlab image version: gitlab/gitlab-ee:16.10.0-ee.0


Solution

  • this code worked for me:

    if jira_integration = Integrations::Jira.first
      puts "post-reconfigure.sh: existing Jira integration found, skip Jira init."
    else
      puts "post-reconfigure.sh: no existing Jira integration found, creating new one ..."
    
      new_jira_integration = Integrations::Jira.new(
        active: true,
        instance: true,
        project_id: nil,
        group_id: nil,
        properties: {
          url: '${JIRA_URL}',
          username: '${JIRA_USER}',
          password: '${JIRA_PASS}',
        }
      )
    
      if new_jira_integration.save
        puts "post-reconfigure.sh: new Jira integration created successfully."
      else
        puts "post-reconfigure.sh: failed to create new Jira integration."
        puts new_jira_integration.errors.full_messages
      end
    end