Skip to content

Support issue creation in separate GitLab instance

Mitchell Nielsen requested to merge 9-support-separate-instance into main

Summary

Supports creating issues in a separate GitLab instance by creating a GitLab client for the pipeline failure, and a GitLab client for the issue tracking. If no separate issue tracking configuration is provided, then the client from the pipeline failure is used.

Closes #9 (closed)

Testing

Setup

#!/bin/bash

# Mocking CI environment
export CI_SERVER_URL=https://gitlab.com/
export CI_PROJECT_ID=28421015
export CI_PIPELINE_ID=346644958
export CI_PIPELINE_URL=https://gitlab.com/mnielsen/issue-bot-examples/-/pipelines/346644958
export CI_COMMIT_SHORT_SHA=1a0f74ec
export CI_COMMIT_REF_NAME=main
export CI_JOB_URL=https://gitlab.com/mnielsen/issue-bot-examples/-/jobs/1470620808

# User-required settings
export ISSUE_BOT_API_TOKEN=<my .com token>

# ----- Option 0: Test creation in same project -----
# No additional configuration needed

# ----- Option 1: Test creation in alternate project -----
export ISSUE_TRACKER_PROJECT_ID=30168573 # .com/issue-bot-examples-2

# ----- Option 2: Test creation in separate instance
export ISSUE_TRACKER_PROJECT_ID=1186     # dev/issue-bot-examples-dev
export ISSUE_TRACKER_BASE_URL=https://dev.gitlab.org/
export ISSUE_TRACKER_API_TOKEN=<my dev token>

# Run
go run .

Results

Edited by Mitchell Nielsen

Merge request reports