Jenkins pipeline for Application provisioning

To create a pipeline job in Jenkins:
  1. Click New Item in the upper left corner of the admin console.
  2. Enter the name of the project.
  3. Select Pipeline.
  4. Under Pipeline, enter the pipeline script, refer to the example pipeline script given here.

    Example Pipeline Script:

    node("master") { stage ('Start')
    { appViewXRaiseRequest(siteName: "admin@https://192.168.142.172:5300", 
    payload:"{\"payload\":{\"data\":{\"input\":{\"requestData\":[{\"sequenceNo\":1,
    \"scenario\":\"scenario\",\"fieldInfo\":{\"fqdn\":\"${AppName}\",\"port\":\"${Port}
    \",\"name\":\"admin\"}}]},\"task_action\":1},\"header\":{\"workflowName\":
    \"Application Provisioning\"}}}",workflow:"Application Provisioning") 
    script { env.logContent = Jenkins.getInstance().getItemByFullName(env.JOB_NAME) 
    .getBuildByNumber(Integer.parseInt(env.BUILD_NUMBER)).logFile.text scr = ''' 
    LOG="$logContent" arr=() while read -r line; do arr+=("$line") done <<< "$LOG" for 
    (( counter = 0; counter <= 15; counter++ )) 
    do if grep -q "requestId" <<< ${arr[counter]}; 
    then echo ${arr[counter]} | sed -e 's/ //g' | cut --complement -d ":" -f 1 fi done 
    ''' env.RequestId = sh (script: scr,returnStdout: true).trim() 
    echo "Request Id - ${RequestId}" } } stage ('ServiceNow - Create Change')
     { appViewXCheckStageStatus(siteName:"admin@https://192.168.142.172:5300", 
    requestId: "${RequestId}", startTask: "", 
    endTask: "servicenow_create_change_2_1_1_2_2_1_3_1_1_1:Create Change Ticket") } 
    stage('DNS Provisioning') { appViewXCheckStageStatus
    (siteName:"admin@https://192.168.142.172:5300", 
    requestId: "${RequestId}", startTask: "", endTask: 
    "script_1:Infoblox - Fetch Free IP's") } 
    stage('Certificate Generation') { appViewXCheckStageStatus
    (siteName:"admin@https://192.168.142.172:5300", requestId: "${RequestId}",
    startTask: "", endTask: "script_2:Certificate Generation") } 
    stage('F5 BIG IP Provisioning') 
    { appViewXCheckStageStatus(siteName:"admin@https://192.168.142.172:5300", 
    requestId: "${RequestId}", startTask: "", endTask: "endWorkOrder_1:WorkOrder") } 
    stage('Firewall Provisioning') { appViewXCheckStageStatus
    (siteName:"admin@https://192.168.142.172:5300", 
    requestId: "${RequestId}", startTask: "", 
    endTask: "bigip_firewall_policy_1:bigip_firewall_policy") } 
    stage ('ServiceNow - Close Change')
    { appViewXCheckStageStatus(siteName:"admin@https://192.168.142.172:5300", 
    requestId: "${RequestId}", startTask: "", 
    endTask: "servicenow_close_change_1_1_1_2_1_1:Close Change Ticket") } } 
  5. Add the contents and click Save.
  6. On the stage view page, where the Pipeline build will be executed, choose Build with Parameters option.
  7. Enter the required inputs to run the workflow and click Build.
  8. The stage view and console output can be seen when the pipeline is executed.
    • Pipeline stages
    • Console Output: Select the globe near the build number under Build History to see the outputs.
    • The request Id of the workflow is shown in the console logs.
  9. The task name, task logs and task status for each task in the workflow also shown in the console logs.
  10. On the Request :: All page, click on the Request ID of any workflow to see the execution of each task in the workflow.
  11. To see the summary of each task in the workflow, under Activity, click View.