Support issue creation in separate project
Summary
Supports issue creation in a separate project by exposing ISSUE_TRACKER_PROJECT_ID environment variable. If set, issues will be created in the specified project. This enables support for custom issue trackers.
Closes #3 (closed)
Testing
Without a custom issue tracker set
#!/bin/bash
export ISSUE_BOT_API_TOKEN=$(cat my-api-token.txt)
export CI_PROJECT_ID=28421015
export CI_PIPELINE_ID=346644958
export CI_JOB_URL="https://gitlab.com/mnielsen/issue-bot-examples/-/jobs/1470620808"
export CI_PIPELINE_URL="https://gitlab.com/mnielsen/issue-bot-examples/-/pipelines/346644958"
export CI_COMMIT_SHORT_SHA=1a0f74ec
export CI_COMMIT_REF_NAME=master
# export ISSUE_TRACKER_PROJECT_ID=29096385
go run main.go
2021/08/24 11:50:59 ISSUE_TRACKER_PROJECT_ID not set, using CI_PROJECT_ID for new issues
2021/08/24 11:51:01 issue does not exist yet. Creating...
2021/08/24 11:51:01 issue created: https://gitlab.com/mnielsen/issue-bot-examples/-/issues/21
With a custom issue tracker set
#!/bin/bash
export ISSUE_BOT_API_TOKEN=$(cat my-api-token.txt)
export CI_PROJECT_ID=28421015
export CI_PIPELINE_ID=346644958
export CI_JOB_URL="https://gitlab.com/mnielsen/issue-bot-examples/-/jobs/1470620808"
export CI_PIPELINE_URL="https://gitlab.com/mnielsen/issue-bot-examples/-/pipelines/346644958"
export CI_COMMIT_SHORT_SHA=1a0f74ec
export CI_COMMIT_REF_NAME=master
export ISSUE_TRACKER_PROJECT_ID=29096385
go run main.go
2021/08/24 11:48:07 setting issue project ID to 29096385
2021/08/24 11:48:07 setting issue title prefix to issue-bot-examples
2021/08/24 11:48:08 issue does not exist yet. Creating...
2021/08/24 11:48:08 issue created: https://gitlab.com/mnielsen/my-other-project/-/issues/6
To validate:
- Check the example issue created: https://gitlab.com/mnielsen/my-other-project/-/issues/6
- Confirm that the source project's name is in the issue prefix
- Confirm that the links direct back to the source project
Edited by Mitchell Nielsen