DevOps Automation

 View Only

Job as Code in UrbanCode Build 6.1.7

By IBM DevOps Expert posted Mon May 09, 2022 02:18 PM

  

UrbanCode Build’s Job-as-Code is an alternate approach to configure job steps, as a simple plain JSON or YAML files. It also avoids configuring the job steps manually in UrbanCode Build UI.

The challenges that users face while configuring job steps is to track the changes done to the job steps. For this problem, UrbanCode Build has a Job-as-Code feature that helps to maintain the configuration file in an SCM repository and versioned.

The configuration file should be kept local to the UrbanCode Build Server. i.e. the configuration file should be placed in the same machine where UrbanCode Build Server is installed.

Here’s a list of the topics covered in this blog:

  1. Preparing the Job as Code config file
    • Creating a Job as Code Config file
    • Step Templates for JSON and YAML Config files
    • Example template for Maven Step Type
  2. Configuring Job as Code in UrbanCode Build

Preparing the Job as Code config file

Creating a Job as Code config file

UrbanCode Build will accept the configuration file either in JSON or YAML formats. Follow the below template while preparing the configuration file.

 

  • JSON Config file template

 

  • YAML Config file template

Step Templates for JSON and YAML Config files

 

  • JSON Step template



  • YAML Step template


Note:

The “stepType” element should be given as “PluginName-CommandName”.

 

To know the plugin name and command name for each Plugin Step, follow the below instructions.

  • Launch the REST API https://<hostaname>:8443/rest2/plugins
  • Read the plugin name and commands name elements from json response and fill the stepType as in the example. “stepType“: “Maven-Maven Build

The Properties element array, should be populated based on the stepType.

Please follow the below instructions to populate the properties array.

  • Launch the REST API https://<hostaname>:8443/rest2/plugins
  • Read the Plugin Command’s properties array “name” and “default values” elements and configure the same as key and value respectively in properties array.
  • Let’s take “Maven Build” plugin command as an example.

This has multiple properties defined as (name, value) pairs. Let’s take one as an example.

name“: “pomFileName“,

defaultValue“: “pom.xml

Now populate the properties array as below,

key“: “pomFileName“,

value“: “pom.xml

 

Example template for Maven Step Type:


 

Configuring Job as Code in UrbanCode Build

  1. Download and load the Job as Code plugin in System > Plug-ins
  2. Create a new step Job as Code.

Click on Job as Code > Configure Job as Code step from the displayed step types.

 

  1. Enter the details for Configure Job as Code step and save.

 


#UrbanCodeBuild
0 comments
4 views

Permalink