With our May 2018 release of Oracle Developer Cloud, we have integrated Oracle Cloud Infrastructure command line interface (from here on, will be using OCIcli in the blog) as part of the build pipeline in Developer Cloud. This blog will help you understand how you can configure and execute OCIcli commands as part of the build pipeline, configured as part of the build job in Developer Cloud.
Configuring the Build VM Template for OCIcli
You will have to create a build VM with the OCIcli software bundle, to be able to execute the build with OCIcli commands. Click on the user drop down on the right hand top of the page. Select “Organization” from the menu.
Click on the VM Templates tab and then on the “New Template” button. Give a template name of your choice and select the platform as “Oracle Linux 7”. And then click the Create button.
On creation of the template click on “Configure Software” button.
Select OCIcli from the list of software bundles available for configuration and click on the + sign to add it to the template. You will also have to add the Python3.5 software bundle, which is a dependency for the OCIcli. Then click on “Done” to complete the Software configuration.
Click on the Virtual Machines tab, then click on “+New VM” button and enter the number of VM you want to create and select the VM Template you just created, which would be “OCIcli” for our blog.
Build Job Configuration
Configure the Tenancy OCID as Build Parameter using String Parameter and give the name as per your wish. I have named it as "T" and have provided a default value to it, as shown in the screenshot below.
In the Builders tab Select OCIcli Builder and a Unix Shell builder in this sequence from the Add Builder drop down.
On adding the OCIcli Builder, you will see the form as below.
For the OCIcli Builder, you can get the parameters from the OCI console. Below screenshots would show where to get each of these form values from the OCI console.Below highlighted are in red boxes shows where you can get the Tenancy OCID and the region for the “Tenancy” and “Region” fields respectively in the OCIcli builder form.
For the “User OCID” and “Fingerprint” you need go to User Settings by clicking over the username drop down in the OCI console located at right hand side top. Please refer the screen shot below.
Please refer the links below for understanding the process of generating the Private Key and configuring the Public Key for the user in the OCI console.
In the Unix Shell Builder you can try out the below command:
oci iam compartment list -c $T
This command will list all the compartment in the Tenancy with OCID given to variable ‘T’ that we configured in the Build parameters tab as a String Parameter.
Post execution of the command, you can view the output on the console log. As shown below.
There are tons of other OCIcli commands that you can run as part of the build pipeline. Please refer this link for the same.
**The views expressed in this post are my own and do not necessarily reflect the views of Oracle