How-to: Deploy applications by using REST commands
The following example describes how to use the REST commands to deploy an application.
Before you begin
About this task
The server that is used in this example is server.example.com. The user is nsmith and the password is passwd.
Procedure
- Create and import a component.
- Use the createComponentProcess PUT command
to create a component process.
The following JSON file represents this component process:curl -k -u nsmith:passwd https://server.example.com:8443/cli/componentProcess/create -X PUT -d @componentProcess.json
{ "active": "true", "component": "helloWorld", "configActionType": "ADD", "defaultWorkingDir": "${p:resource/work.dir}/${p:component.name}", "description": "", "inventoryActionType": "ADD", "name": "helloProcess", "propDefs": [], "rootActivity": { "children": [ { "allowFailure": false, "children": [], "commandName": "Delete Files and Directories", "impersonationUseSudo": false, "name": "Clean work space", "pluginName": "File Utils", "pluginVersion": 31, "properties":{ "baseDir":".", "includes":"*", "excludes":"", "followSymlinks":"false", "caseSensitive":"true" }, "showHidden": false, "type": "plugin", "useImpersonation": false }, { "allowFailure": false, "children": [], "commandName": "Download Artifacts", "impersonationUseSudo": false, "name": "Download Artifacts", "pluginName": "IBM UrbanCode Deploy Versioned File Storage", "pluginVersion": 18, "properties":{ "directoryOffset":".", "artifactSetBaseDir":"", "fileIncludePatterns":"**/*", "fileExcludePatterns":"", "syncMode":"true", "fullVerification":"true", "setFileExecuteBits":"false", "verifyFileIntegrity":"false", "repositoryUrl":"${p:server.url}/vfs", "repositoryId":"${p:component/code_station/repository}", "label":"${p:version.name}", "serverUrl":"${p:server.url}", "compId":"${p:component.id}", "resId":"${p:resource.id}", "charset":"" }, "showHidden": false, "type": "plugin", "useImpersonation": false }, { "allowFailure":false, "children": [], "commandName":"Create .zip File", "impersonationUseSudo":false, "name":"Compress artifacts", "pluginName":"File Utils", "pluginVersion":31, "properties":{ "zipName":"helloWorld.zip", "baseDir":".", "includes":"*", "excludes":"", "update":"false", "followSymlinks":"false", "caseSensitive":"true" }, "showHidden": false, "type": "plugin", "useImpersonation": false }, { "allowFailure":false, "children": [], "commandName":"Move Directory", "impersonationUseSudo":false, "name":"Deploy artifacts", "pluginName":"File Utils", "pluginVersion":31, "properties":{ "sourceDir":".", "destDir":"${p:helloHome}/target", "includes":"*.zip", "excludes":"", "mapperRules":"" }, "showHidden": false, "type": "plugin", "useImpersonation": false }, { "children": [], "name": "FINISH", "type": "finish" } ], "edges": [ { "to": "Clean work space", "type": "ALWAYS", "value": "" }, { "from": "Clean work space", "to": "Download Artifacts", "type": "ALWAYS", "value": "" }, { "from": "Download Artifacts", "to": "Compress artifacts", "type": "ALWAYS", "value": "" }, { "from": "Compress artifacts", "to": "Deploy artifacts", "type": "ALWAYS", "value": "" }, { "from": "Deploy artifacts", "to": "FINISH", "type": "ALWAYS", "value": "" } ], "name": "GRAPH", "offsets": [ { "name": "Clean work space", "x": "-65", "y": "90" }, { "name": "Download Artifacts", "x": "-70", "y": "210" }, { "name": "Compress artifacts", "x": "-70", "y": "290" }, { "name": "Deploy artifacts", "x": "-65", "y": "370" }, { "name": "FINISH", "x": "-60", "y": "450" } ], "type": "graph" }, "status": "Active", "takesVersion": "true" }
The command returns a result that is similar to the following JSON information:{ "id":"12f65517-5fc1-44ff-a58b-2401cfba8f2f", "name":"helloProcess", "description":"", "defaultWorkingDir":"${p:resource\/work.dir}\/${p:component.name}", "takesVersion":true, "inventoryActionType":"ADD", "status":"Active", "active":true, "versionCount":1, "version":1, "commit":0, "path":"components\/cf355787-a772-4533-be45-3e169e9da6eb\/processes\/12f65517-5fc1-44ff-a58b-2401cfba8f2f" }
- Create an application, and then associate the component
with the application.
- Create an environment, and associate it with a resource.
- Use the createApplicationProcess PUT
command to create an application process.
The following JSON file represents the application process. The application ID is the same as the ID that is returned in step 3.curl -k -u nsmith:passwd https://server.example.com:8443/cli/applicationProcess/create -X PUT -d @applicationProcess.json
{ "application": "932452cc-3562-4545-8de5-c57aa7efbcc4", "description": "", "inventoryManagementType": "AUTOMATIC", "name": "hello App Process", "offlineAgentHandling": "PRE_EXECUTION_CHECK", "rootActivity": { "children": [ { "children": [{ "children": [{ "allowFailure": false, "children": [], "componentName": "helloWorld", "componentProcessName": "helloProcess", "name": "Deploy helloWorld", "properties": {}, "type": "componentProcess" }], "componentName": "helloWorld", "name": "inventoryVersionCheck", "status": "Active", "type": "inventoryVersionDiff" }], "componentName": "helloWorld", "failFast": "false", "maxIteration": "-1", "name": "Deploy helloWorld", "runOnlyOnFirst": "false", "type": "componentEnvironmentIterator" }, { "children": [], "name": "FINISH", "type": "finish" } ], "edges": [ { "to": "Deploy helloWorld", "type": "ALWAYS", "value": "" }, { "from": "Deploy helloWorld", "to": "FINISH", "type": "ALWAYS", "value": "" } ], "name": "GRAPH", "offsets": [ { "name": "Deploy helloWorld", "x": "-35", "y": "210" }, { "name": "FINISH", "x": "0", "y": "420" } ], "propDefs": [], "type": "graph" } }
The command returns a result that is similar to the following JSON information:{ "id":"37d563ce-7885-48f1-b8c0-f79046c0f024", "name":"hello App Process", "description":"", "active":true, "inventoryManagementType":"AUTOMATIC", "offlineAgentHandling":"PRE_EXECUTION_CHECK", "versionCount":1, "version":1, "commit":0, "path":"applications\/932452cc-3562-4545-8de5-c57aa7efbcc4\/processes\/37d563ce-7885-48f1-b8c0-f79046c0f024" }
- Use the requestApplicationProcess PUT
command to deploy the application.
The following JSON file represents the deployment request:curl -k -u nsmith:passwd https://server.example.com:8443/cli/applicationProcessRequest/request -X PUT -d @applicationDeploy.json
{ "application": "hello Application", "applicationProcess": "hello App Process", "environment": "helloDeploy", "versions": [{ "version": "1.0", "component": "helloWorld" }] }
The command returns a result that is similar to the following JSON information:{"requestId":"bffff82f-ff69-4c07-b010-26ca3f21be39"}