KBEC-00521 - CloudBees CD/RO How to get the user who approved a manual step in a pipeline step

1 minute readKnowledge base

Issue

When you use a manual task in your pipelines, it is often necessary to get information on the user or users who approved the task.

Environment

Resolution

There are multiple potential approaches that you could take to cover this use case. One of them would be to create a task of type "Command" that would get that information for you.

Command shell: ec-perl

use strict;
use ElectricCommander;

my $cmdr = ElectricCommander->new();
# Returns an xPath object containing the runtime details.
my $xpath = $cmdr->getPipelineRuntimeDetails({flowRuntimeId => "$[/javascript myPipelineRuntime.flowRuntimeId]"});

# We search for the corresponding attribute to get the value.

my $approver = $xpath->find("//approvedByUsers/approvedBy");

print "$approver"

This is a simple approach to cover the use case at hand.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.