How to output link to gitlab job for Fastlane Scan Results in Slack

Viewed 102

Is there a way to create a link to the gitlab job that ran when outputting the result of a Fastlane Scan to Slack?

enter image description here

enter image description here

I want to have a link from within the Slack results to the gitlab job that ran.

2 Answers

The slack_message argument supports Slack Flavoured Markdown, so you can pass a URL to it and it will link in Slack. So for example

slack_message: "QA UI Tests on iPhone 13 Pro"

should change to

slack_message: "<https://gitlab.com/link-to-job-that-you-provide|QA UI Tests on iPhone 13 Pro>"

And then that text will become a link to the job.

I was able to do this by adding the following to our gitlab-ci.yml file:

script:
    - export JOB_ID=$CI_JOB_ID

And then in our fastlane file, I adjusted the slack_message field within the scan section:

slack_message: "CI Job: https://<urltogitlab>/" +  ENV['JOB_ID'],
Related