Configuration Steps for Workflow API for Features
Prerequisites
-
You have an SAP BTP subaccount and enabled the SAP Build Process Automation service.
-
You configured a shared environment. For more information, see Environments.
-
You added your API key to your shared environment. For more information, see Add API Keys to an Environment.
Context
With the Workflow API you can initiate workflow actions for an external system for the following feature status transitions to:
-
Start Implementation
-
Handover to Test
-
Successfully Tested
-
Approve for Production
-
Confirm Deployment
If you switch to a previous status, no workflow is triggered.
Creating a Destination in your SAP Cloud ALM Tenant
First you have to create a destination in your SAP Cloud ALM tenant to connect to the SAP Build Process Automation service. This destination is used by SAP Cloud ALM to initiate the workflow.
-
Navigate to the BPA service instance and create a service key.
-
In the BTP Cockpit, choose Instances and Subscriptions and select Create.
-
Enter the following information:
-
Service: SAP Build Process Automation
-
Plan: standard
-
Runtime Environment: Cloud Foundry
-
Space: the name of your space
-
Instance Name: enter a name for the instance
-
-
Select the created instance.
-
In the Service Keys section, select Create.
-
Enter a Service Key Name and select Create.
-
-
Open the service key and copy the uaa/clientid, uaa/clientsecret, uaa/url and endpoints/api values.
-
Create a new destination in your SAP Cloud ALM tenant with the following values:
-
Name: <any name (destinationName)>
-
Type: HTTP
-
URL: <url from endpoints/api>/workflow/rest/v1/workflow-instances
-
Proxy Type: Internet
-
Authentication: OAuth2ClientCredentials
-
Client ID: <uaa/clientid>
-
Client Secret: <uaa/clientsecret>
-
Token Service URL: <uaa/url>/oauth/token
-
URL.headers.api-key: <API Key of your shared environment>
-
Creating a Workflow in External Workflow Management Systems
To define process input variables in the external workflow management system, you can refer to the Features Events and Response Payload Resource format.
These have to be included in the new mapping, see "Creating a new Mapping" in Adding your Subscription in SAP Cloud ALM - External API Management.
To define the mapping, the attributes related to the Feature will be located under the property 'item' as described in Workflow Events and Response Payload.
Adding your Subscription in SAP Cloud ALM - External API Management
In the External API Management app in your SAP Cloud ALM tenant, you can create a webhook and mapping.
Creating a New Webhook
In the Webhooks Management tab, select + to create a new webhook.
-
Name: <any name> (identifier to map to the subscription)
-
Destination Source: BTP Destination
-
Destination Id: <destinationName> (has to match the destination name created in the previous step)
-
Destination Type: Other
-
Ext. Resource Type: Workflow
Creating a New Mapping
In the Mappings Management tab, select + to create a new mapping.
-
Source: SAP Cloud ALM
-
Description: <any description> (identifier to map to subscription)
-
Destination: SAP Build Process Automation
-
Version: REST API v1
-
Mapping Type: Payload Based
Mapping Rules
This section shows you the code template for the mapping. Below the template, you find explanations of the parts of the code that you can configure.
For more information about mapping in general, see Mapping.
|
|
Mandatory Mapping
You have to configure these mandatory parameters in the mapping:
-
externalResourceId: Id of the workflow
-
externalResourceStatus: status of the workflow
As defined in the default mapping, these following values are accepted:
-
RUNNING
-
CANCELED
-
ERRONEOUS
-
COMPLETED
-
Completed
-
SUSPENDED
These values are then mapped to the accepted values:
-
STARTED: in case workflow has not been accepted or rejected
-
FAILED: in case workflow has been rejected
-
COMPLETED: in case workflow has been accepted
Optional Mapping
-
externalApprovers: included in the history entry when a workflow is approved or rejected. If it isn't included, nothing is displayed about it in the history entry.
-
externalDecision: We are expecting from our application APPROVED or REJECTED. If this parameter is enabled but the Features app doesn't receive one of these two values, even though the workflow will be completed, the status is set to failed.
You have to add the parameters manually to the mapping:
|
|
Creating a New Subscription
In the Subscriptions tab, select + to create a new subscription.
-
Name: <any name> (identifier to map to subscription)
-
Description: <any description> (identifier to map to subscription)
-
Webhook: <webhookName> (has to match the webhook name created in the previous step)
-
Mapping: <mappingName> (has to match the mapping name created in the previous step)
-
Resource Type: Workflow
-
Type: Built-in
Variables:
-
workflowDefinitionId: <workflowDefinitionId>
This refers to the workflow definition ID you created in Creating a Workflow in External Workflow Management Systems.
-
workflowEnvironmentId: <workflowEnvironmentId>
This refers to the environment ID where your BPA workflow was deployed.
Assigning the Workflow to a Project
-
Open the Projects and Setup app.
-
Select the project you want to assign the workflow to.
-
Open the Subscriptions section and select the subscription you created in the previous step for Feature.
Testing the Workflow
-
Navigate to the SAP Build Process Automation app.
-
Select Inbox.
-
Approve or reject the workflow.