Pipeline Script


Pipeline script summary

In pipeline stage step definition, there is a step called script, which allows users to execute script in the server where IDA is deployed.

Define script

In Edit Step modal, select Script as Type then you can define one or more scripts in Script text area. For multiple scripts, each of them need to start from a new line.



Script supported parameters

IDA supports below parameters in Script. They can be used in Script to represent Pipeline related attributes.

${PIPELINE_NAME}: current pipeline name
${PIPELINE_ID}: current pipeline ID
${STAGE_NAME}: current stage name
${STEP_NAME}: current step name
${BUILD_ID}: current build id
${BUILD_REPORT_URL}: current build report URL(relative path)
${APP_ACRONYM}: current processApp acronym name
${SNAPSHOT_ACRONYM}: current snapshot acronym name

Script samples

Call RESTFul service

You can use curl to call a RESTful service or Web Service in Script. For example, below script calls a Workflow REST API by curl.

curl -H “Accept:application/json” -H “Authorization:Basic YWRtaW46UGFzc3cwcmQ=” -k https://[serverhost]:[port]/rest/bpm/wle/v1/systems

Call Web Service

You can also use curl to call a Web Service. For example, you can call a Web Service to send email notification during pipeline creation. Assume the Web Service is based on SOAP 1.2 and its WSDL URL is: http://[serverhost]:[port]/teamworks/webservices/HSS/SendEmailWS.tws?wsdl, you can use below curl script to call it.

curl -H “Content-Type: application/soap+xml;charset=utf-8” -d “${PIPELINE_NAME} resultPlease refer to ${BUILD_REPORT_URL}ida-mock@cn.ibm.comida-mock@cn.ibm.com” http://[serverhost]:[port]/teamworks/webservices/HSS/SendEmailWS.tws


Call wsadmin command

You can execute a wsadmin command in Script. The wsadmin command is running against the BAW server associated to the Stage Workflow configuration. For example,

ssh AdminTask.BPMSetEnvironmentVariable(‘[-containerAcronym ${APP_ACRONYM} -containerSnapshotAcronym ${SNAPSHOT_ACRONYM} -environmentVariableName TEST_KEY -environmentVariableValue 8899]’)

This Script first logon BAW server using ssh, then execute the wsadmin commmand there to update the Workflow environment variable. The format of the Script to call wsadmin command is

ssh + space + wsadmin command

We also support execute script file for wasadmin command including parametes. For example,

ssh -f /tmp/bpmtask.py

ssh -f bpmtask.py

ssh -containerAcronym BTAS -containerSnapshotAcronym T1 -f /tmp/bpmtask.py

ssh -containerAcronym ${APP_ACRONYM} -containerSnapshotAcronym ${SNAPSHOT_ACRONYM} -f /tmp/bpmtask.py

The script file has a .py extension to reflect the Jython language syntax of the script. Example below shows a two-line Jython script file named bpmtask.py.

  print "This script is used to set BAW EnvironmentVariable"
  AdminTask.BPMSetEnvironmentVariable('[-containerAcronym BTAS -containerSnapshotAcronym TS -environmentVariableName TEST_KEY -environmentVariableValue 98744]')

Notes

  • If you not specify the script file path,it will use the BAW deployment remote dir as your script path,which is defined in the IDA setting page.Also you need to put this script file in the BAW server specfied folder before you run the pipeline.
  • ${APP_ACRONYM} and ${SNAPSHOT_ACRONYM} parameter will be replaced by runtime.

The format of the script file to call wsadmin command is

ssh + space + -f + space + scriptFileName ssh + space + Parameters + space +-f + space + scriptFileName

Categories:

Updated: