Copy an application process in UCD quickly from one project to another

Off
Strongback Consulting

Here’s the scenario: You’ve got an application process in one project area for IBM Urbancode Deploy. Its taken time to develop, and you’ve spent many hours debugging it. Then you realize you don’t have a “copy” feature for an application process.

Ooops.

Now you’re worried you’ve got to hand build the process in other project areas (and you’re not using an application template). This could be a tedious, error prone process!

Fear not!

TLDR;

Here’s is what you can do if you’re impatient and don’t want to read details:

  • Export the application to JSON
  • Open the JSON in Notepad++, and cut out just the application process you want to copy.
  • Modify the JSON
  • Add it to a “Create Application Process” step in a generic process.
  • Run the generic process against a target application

Now for the details:

Export The application. To do this, go to the Applications tab. Hover over the application, and when the ellipsis (…) shows, click on it. Then click ‘Export’. This will save a json file to your Downloads folder.

Edit the JSON file. Open it up in Notepad++ (or Notepad or whatever decent editor you’ve got). Remove everything but the process you’re wanting the copy. Just do a search for the process name, and look for the opening and closing braces.

Next, you’ll need to add the “application” attribute. Provide it the value of ${p:app.name}. This is a process level property that we will supply at run time (and it allows us to run it multiple times for each application we want to copy the process into). Below is an example of what the top the JSON would look like

{
  "name": "Application process name",
  "application": ${p:app.name}",
  "description": "Description. This template includes one 
  step, which deploys a component.",
  "inventoryManagementType": "The inventory management for 
  the process request, such as AUTOMATIC",  
  "offlineAgentHandling": "PRE_EXECUTION_CHECK",
  "propDefs": [{
    "label": "Property label",
    "name": "Property name",
    "type": "TEXT"
    ...

Here comes the fun part (especially for those of you who did the TLDR route.

If your process has properties that are application properties, you must escape the special characters of the property. Otherwise, when you run the generic process that copies this application process into an application, it will fail because the generic process will try to populate the variables. Here’s an example:

${p:my.application.property}

Should be escaped to look like:

\$\{\p\:my.application.property\}

Don’t forget to escape the trailing brace! Otherwise, it will prematurely close the JSON section. Now, that you have your JSON ready, create a generic process (these are the ones under the “Process” tab).

Add the “Create Application Process” step from the palate to your editor. This is the only step you need.

Edit the process and paste in the JSON you created in your text editor.

Now, go to the Configuration section of this generic process. Click on the Process Properties, and add one for “app.name”. Give it the label “Application”.

Now, click on the Dashboard, and test your generic process. Enter the target application name, and click Submit.

If all goes well, it will write that application process into your target application. If not, you may need to go back and tweak the JSON file. The most common issue you’ll find is an errant property that you forgot to escape out, or you forgot to escape the trailing curly brace.

References

While this was done using a generic process allowing you to execute this on an application by application basis, you can use the UCD Rest Client:

https://www.ibm.com/support/knowledgecenter/en/SS4GSP_7.0.4/com.ibm.udeploy.api.doc/topics/udclient_createapplicationprocess.html

Comments are closed.

Strongback Consulting