How can I send an Allure report link to Slack?

For example, I have three last steps in my pipeline and I would like to have not only the message in slack but also a link to the allure report as well

prepare:
title: “Prepare report”
stage: “prepare”
image: ‘ubuntu’ # The image in which command will be executed
working_directory: “${{clone}}” # Running command where code cloned
commands:
- “cp -r -f ./allure-results $CF_VOLUME_PATH/allure-results”

generate:
title: Generate test reporting
stage: “generate”
image: codefresh/cf-docker-test-reporting
working_directory: ‘${{CF_VOLUME_PATH}}’
environment:
- CLEAR_TEST_REPORT=true
- BUCKET_NAME=example-allure-reports
- CF_STORAGE_INTEGRATION=allure

slack notify:
title: Slack notify
stage: “slack notify”
type: slack-notifier
arguments:
SLACK_HOOK_URL: “${{SLACK_HOOK_URL}}”
SLACK_TEXT: “Test completed”

An output from the “generate” stage is

All 92 report files was successfully uploaded
You can access report on:
https://g.codefresh.io/api/testReporting/v2/5ff4681a40143fwfwffds1ec/main/s3/allure/example-allure-reports/6033729asdsadf342a/index.html
Start removing test report folder
Annotation cf_test_reporter_link was created.

How can I get this URL after every single pipeline run and post it to slack?

What about a pipeline hook?

Thank you for your answer. The main problem is this annotation “cf_test_reporter_link”. I see it generated in the console log but unfortunately, I can’t get it and transfer it to Slack.

You should be able to get all annotations with the Codefresh CLI in a pipeline Annotations · Codefresh | Docs

I need to double check if the test report is always annotating with the URL, but I believe it does. You can easily use the Codefresh CLI in a pipeline step Codefresh API · Codefresh | Docs

To use Codefresh CLI I have to set ‘image: codefresh/cli’ and yes, from here I can get an annotation but the main problem is the Slack step.

slack notify:
  title: Slack notify
  stage: “slack notify”
  type: slack-notifier
    arguments:
      SLACK_HOOK_URL: “${{SLACK_HOOK_URL}}”
      SLACK_TEXT: “Test completed”

I can’t use image: codefresh/cli here or maybe I just don’t know how to do it. How I can get an annotation for this step?

You need to use two steps. One with codefresh cli and cf_export to create an environment variable with the result. And one with slack that uses the result

Here is the idea (just pseudocode)

version: '1.0'
steps:
  allure_link_fetch:
    title: Getting Test URL
    image: codefresh/cli
    commands:
      - 'TEST_URL =$(codefresh get annotation ...)
      - cf_export TEST_URL
  slack_notify:
    title: Slack notify
    stage: “slack notify”
    type: slack-notifier
    arguments:
      SLACK_HOOK_URL: “${{SLACK_HOOK_URL}}”
      SLACK_TEXT: “Test completed at $TEST_URL”

Does that help?

I have already tried this case and the console log of the previous step (Before Slack) is here

Executing command: TEST_URL= (codefresh get annotation build {{CF_BUILD_ID}})
Successfully ran freestyle step: Get report
Reading environment variable exporting file contents.


Executing command: cf_export TEST_URL
Exporting TEST_URL=
Reading environment variable exporting file contents.

I can have an output to the console of what I want.
The next step is to save this URL in the variable and transfer it to the last step which is Slack.

get report:
title: Get report
stage: “get report”
image: codefresh/cli
commands:
- ‘codefresh get annotation build ${{CF_BUILD_ID}} cf_test_reporter_link’
- cf_export cf_test_reporter_link

slack notify:
title: Slack notify
stage: “slack notify”
type: slack-notifier
arguments:
SLACK_HOOK_URL: “${{SLACK_HOOK_URL}}”
SLACK_TEXT: “Test completed $cf_test_reporter_link”


and I don’t know how to do it.

Try this:

get report:
  title: Get report
  stage: “get report”
  image: codefresh/cli
  commands:
    -  cf_export cf_test_reporter_link=$(codefresh get annotation build ${{CF_BUILD_ID}} cf_test_reporter_link -o json | jq -r '.value')

Thank you man a lot!!! You saved my life