Aria Automation Service Broker

Aria Automation catalog item request with Jenkins and PowerVRA

In this article, we will discuss how we can use the PowervRA PowerShell library with Jenkins to establish a connection to VMware Aria Automation and trigger Service Broker catalog item requests as Jenkins automation jobs. Before we proceed It will be useful to familiarise with relevant concepts, platforms, and services.

What is Jenkins?

Jenkins is a Java-based open-source automation server that enables developers to reliably build, test, and deploy their software. It is used to continually create and test software projects, making it easier for developers and DevOps engineers to integrate changes to the project and for consumers to get a new build.

What is Aria Automation?

VMware Aria Automation is a platform where you build and manage modern applications. It provides a consistent self-service experience for users, regardless of the underlying cloud provider. Aria Automation also provides governance and resource lifecycle management capabilities, which help organizations control costs and ensure compliance with policies.

The VMware Aria Automation Service Broker provides a single point where you can request and manage catalog items. As a cloud administrator, you create catalog items by importing released VMware Aria Automation Assembler cloud templates and Amazon Web Services CloudFormation templates that your users can deploy to your cloud vendor regions or datastores. A catalog item could also be an entry point for a VMware Aria Automation Orchestrator workflow.

As a user, you can request and monitor the provisioning process. After deployment, you manage the deployed catalog items throughout the deployment lifecycle.

For this article, we will use the catalog item called “Catalog Item Request via Jenkins and PowerVRA” which allows the Aria Automation Service Broker user to trigger an Aria Automation Orchestrator workflow:

For simplicity, the request form only has one input parameter called “input_1”:

What is PowervRA?

PowervRA is a PowerShell module built on top of the services exposed by the VMware Aria Automation REST API. It helps you manage Aria Automation environments using PowerShell scripts. It is a community project and is not in any way supported by VMware

Prerequisites :

  • Jenkins installed on a Windows machine
  • PowerShell plugin installed (enabled) in Jenkins
  • PowervRA module downloaded on the machine where Jenkins is installed
  • Connectivity between the machine where Jenkins is installed and Aria Automation

Step 1: Create a parameterized PowerShell Project (Job)  in Jenkins

From the main dashboard, navigate to “New Item,” and enter a preferred name for your Jenkins job, e.g. “My freestyle project”. Select “Freestyle project,” then click OK to create the project.

After creating the project, this will bring you to the “Configure Project” page. Enter the project description and then check “This project is a parameterized item” from the list below.  For the purpose of our article, we will add 5 parameters for our sample PowerShell script:

  • vraServer – FQDN or IP of our Aria Automation instance. The parameter’s type is “String Parameter”.
  • vraUsername – username used to establish a connection to our Aria Automation instance. The parameter’s type is “String Parameter”.
  • vraPassword –  password used to establish a connection to our Aria Automation instance. The parameter’s type is “Password Parameter”.
  • vraProjectName – the name of the project used for the Service Broker catalog item request. The parameter’s type is “String Parameter”.
  • powervRAPath – the PowervRA module location on the local system. The parameter’s type is “String Parameter”.

Step 2: Configure the Jenkins project to run PowerShell

In the “Build Steps” section of the project settings, click “Add Build Step” and select “PowerShell” so that Jenkins can run the PowerShell script that we’ll paste in.

Step 3: Enter the sample PowerShell script in Jenkins

Before using a PowerShell script in Jenkins, you’ll need to modify it so that the parameters that users enter will be passed into the script. This involves accessing and changing the variables you use from $ParameterName to $($env: ParameterName).

First, we need to import the downloaded PowervRA module from the local file system:

Import-Module -Name $($env:powervRAPath)\PowervRA -Verbose

Next, we need to establish a secure connection to Aria Automation using the credentials specified as script parameters and the PowervRA function Connect-vRAServer:

$SecurePassword = ConvertTo-SecureString $($env:vraPassword) -AsPlainText -Force

Connect-vRAServer -Server $($env:vraServer) -Username $($env:vraUsername) -Password $SecurePassword

After we have established a connection to Aria Automation, we need to acquire a reference to the Service Broker catalog item that we are going to request and a reference to the Aria Automation project used for the request. We will use the value “Catalog Item Request via Jenkins and PowerVRA” for the catalog item name and the value specified as a script parameter for the project name and the PowervRA functions Get-vRACatalogItem and Get-vRAProject:

$catalogItem = Get-vRACatalogItem -Name 'Catalog Item Request via Jenkins and PowerVRA'

$project = Get-vRAProject -Name $($env:vraProjectName)

Now that we have the catalog item that we are going to request and the project, we can prepare the payload for the Aria Automation REST API request in JSON format and execute the Service Broker catalog item request. The payload must include the new deployment name, the project ID, and the request form inputs. In our example, we have only one request form input called “input_1” to which we are passing the value “Test value” and we are creating deployment with the name “Catalog Item Request via Jenkins and PowerVRA 1”. We will use the PowervRA function Invoke-vRARestMethod passing to it the payload and the URI with the catalog item ID:

$json = @"{   

"deploymentName": "Catalog Item Request via Jenkins and PowerVRA 1",

"projectId": "$($project.Id)",

"bulkRequestCount": 1,

  "inputs": { "input_1": "Test value" }

}"@

$apiUrl = "/catalog/api/items"

$uri = "$apiUrl/$($catalogItem.Id)/request"

Invoke-vRARestMethod -Method POST -URI $uri -Body $json -WebRequest

Paste the sample script into the PowerShell “Command” area in Jenkins and save.

Step 4: Test/Run the sample Jenkins job

You (or anyone else with access) can now run the script using the “Build With Parameters” button that will appear on the main dashboard.

The triggered parameterized Jenkins job will authenticate toward the specified Aria Automation instance using the specified credentials and it will request the Service Broker catalog item “Catalog Item Request via Jenkins and PowerVRA” resulting in a new deployment in Aria Automation with the name “Catalog Item Request via Jenkins and PowerVRA 1”:

Related VMware documentation: