Pending Approval notification

Hi, I was wondering if anyone could help with some functionality?
I’ve had a quick look in the forum and online but couldn’t see anything related to what we are trying to do.

Basically, on the pending-approval step. You have an output like Step has been approved by: some-name What I’d like to do is pass that name to a slack message in the next step. Is this even possible?
Thanks

Hey!

Yes, this is possible by using the Step Member Variables, the Approval step have the following variables exposed:

  • authEntity.name
  • authEntity.type

So you can get the name in the following step by using this variable: ${{<Approval_step_name>.authEntity.name}}

Thats brilliant thanks. I did spot those vars elsewhere but didn’t realise they were members of that step :+1:

Hi I’m trying to do this too but I can’t seem to get it to work. Any suggestions? Thanks!

My pipeline looks like this:

version: 1.0

steps:
  askForApproval:
      type: pending-approval
      title: Deploy to production?
      fail_fast: false
      timeout:
        duration: 2
        finalState: denied
        timeUnit: hours
        
  ifApprovedSendSlackNotification:
    type: slack-post-channel
    arguments:
      SLACK_TOKEN: "${{SLACK_TOKEN}}"
      SLACK_CHANNEL: "#elisha-test"
      SLACK_MESSAGE: "${{askForApproval.authEntity.name}}"

But my slack message shows: ${{askForApproval.authEntity.name}}

I also tried with SLACK_MESSAGE: "${{steps.askForApproval.authEntity.name}}" but again my slack message is: ${{askForApproval.authEntity.name}}

Thanks!

We got ours working well. Here’s a snippet of the code we’ve used. We are exporting the variable to send to another pipeline, but in essence what you’ve used in ${{steps.askForApproval.authEntity.name}} should work I would say.

another test would be add a step like the below but with the command - echo ${{steps.askForApproval.authEntity.name}}

deploy_uat_by:
    stage: deploy-to-uat
    type: freestyle
    title: UAT Approval
    image: "gradle:7-jdk11-alpine"
    commands:
      - export UAT_APPROVER=${{steps.approval_to_deploy_uat.authEntity.name}}
      - cf_export UAT_APPROVER