Pipeline yaml


Azure DevOps pipelines allow triggering by events within the underlying SCM, for example, "every time a change gets pushed to the master branch. In our case, the SCM is ISPW, and we will trigger the pipeline using Code Pipeline webhooks. Therefore, we do not use trigger.

trigger: none

Agent pool

The agent pool allows specifying requirements for an agent to fulfill in order to be eligible for execution. In our case, we need to run on the only existing local agent, which resides in the Default agent pool.

pool:
  name: 'Default'

Variables / Constants

Next to the variables defined via the interface, the pipeline will use the variable group mainframe-pipeline-parameters and some additional variables that are used as constants. Refer to the Azure DevOps documentation on how to define and use variables in pipelines.

variables:
- group: 'mainframe-pipeline-parameters'
- name: 'gitRepo'
  value: 'FTSDEMO_$(ispwApplication)_Unit_Tests'
- name: 'ccSystem'
  value: 'AZURE_$(ispwContainerName)'
- name: 'ccDdio'
  value: 'SALESSUP.$(ispwApplication).$(ispwLevel).LOAD.SSD'
- name: 'sonarProjectName'
  value: 'RNU_$(ispwApplication)_Azure'
- name: 'sonarSources'
  value: '.\$(ispwApplication)\MF_Source'

Stages, jobs, tasks

As with Jenkins jobs, there are different elements that help structure the pipeline. Also, they allow defining conditions under which certain tasks get executed, based on results of previous jobs. Refer to the Azure DevOps documentation on details about stages, jobs and tasks.

stages:


Stage preparation

The preparation stage clears the workspace to use and downloads the required assets, like sources from ISPW and the Topaz for Total Test projects from GitHub.

- stage: preparation
  displayName: Preparation
  jobs:

Job getAssets

- job: getAssets
    displayName: Get Assets from Mainframe and GitHub
    steps:

Execute an inline PowerShell script. This script will take the ispwLevel passed by the webhook (DEV1, DEV2, or DEV3), determine the name of the corresponding QA level and create a new variable (echo "##vso[task.setvariable variable=ispwTargetLevel]$ispwTargetLevel"). This latter is necessary, since normal variable definition does not allow this kind of calculation. Therefore, we need to define a new variable during execution.

    - task: PowerShell@2
      displayName: Determine ISPW Target Level
      name: setTargetLevel
      inputs:
        targetType: 'inline'
        script: |
          $ispwTargetLevel = 'QA' + '$(ispwLevel)'.Substring('$(ispwLevel)'.Length - 1, 1)
          Write-Host 'Determined Level ' $ispwTargetLevel
          echo "##vso[task.setvariable variable=ispwTargetLevel]$ispwTargetLevel"

Execute PowerShell script Clear_Workspace-ps1 to clear the designated workspace on the agent.

    - task: PowerShell@2
      displayName: Clear Workspace
      inputs:
        filePath: '$(agentScriptsPath)\Clear_Workspace.ps1'
        arguments: '$(workspaceRoot)'

Execute PowerShell script ISPW_Download_Container-ps1 to download the components in the ISPW container passed by the webhook.

Warning

Important

The CLI configuration location should not be used to download source. This location is cleared during each CLI execution. If your script has been modified to use an alternate configuration location using the -configuration option, specify a different location to download source using the -targetFolder argument.

    - task: PowerShell@2
      displayName: Download sources for assignment
      inputs:
        filePath: '$(agentScriptsPath)\ISPW_Download_Container.ps1'
        arguments: '$(workspaceRoot) $(hostUri) $(hostPort) $(hostUser) $(hostPassword) $(hostCodePage) $(ispwConfig) $(ispwContainerName) $(ispwContainerType) $(ispwTargetLevel) $(cliPath)'

 
Execute PowerShell script Git_Clone_TTT_Repo-ps1 to clone the GitHub repository storing the Topaz for Total Test projects.

    - task: PowerShell@2
      displayName: Get Unit Tests
      inputs:
        filePath: '$(agentScriptsPath)\Git_Clone_TTT_Repo.ps1'
        arguments: '$(workspaceRoot) $(gitProject)/$(gitRepo)'


Stage tests

This stage executes the downloaded tests and gets the Code Coverage results.

- stage: tests
  displayName: Tests
  jobs:


Job runTests

  - job: runTests
    displayName: Run unit tests and get results
    steps:

  
Execute PowerShell script TTT_Run_Tests-ps1 to execute the tests. The script will execute only tests for those components that have been downloaded for the container.

    - task: PowerShell@2
      displayName: Execute Unit Tests
      inputs:
        filePath: '$(agentScriptsPath)\TTT_Run_Tests.ps1'
        arguments: '$(workspaceRoot) $(hostUri) $(hostPort) $(hostUser) $(hostPassword) $(hostCodePage) $(ispwApplication) $(ispwLevel) $(ccRepo) $(ccSystem) $(ccTestId) $(cliPath)'

   
Execute PowerShell script 'Code_Coverage_Download_Metrics-ps1' to download the Code Coverage results from the mainframe repository to the workspace.

    - task: PowerShell@2
      displayName: Get Code Coverage Results
      inputs:
        filePath: '$(agentScriptsPath)\Code_Coverage_Download_Metrics.ps1'
        arguments: '$(workspaceRoot) $(hostUri) $(hostPort) $(hostUser) $(hostPassword) $(hostCodePage) $(ispwApplication) $(ccRepo) $(ccSystem) $(ccTestId) $(ccDdio) $(cliPath)'


Stage qualityGate

This stage will pass the results to SonarQube, query the quality gate status and based on the result, if the quality was passed, trigger the corresponding release pipeline, or regress the assignment, if the quality gate was failed.

- stage: qualityGate
  displayName: Quality Gate
  jobs:


Job sonar

The job will execute the Sonar scanner and query the quality gate.

  - job: sonar
    displayName: run Sonar Scan, Check Quality Gate
    steps:

Execute PowerShell script Sonar_Scan-ps1 to pass sources, test results and code coverage data to SonarQube, using the sonar scanner.

    - task: PowerShell@2
      displayName: Run Sonar Scanner
      inputs:
        filePath: '$(agentScriptsPath)\Sonar_Scan.ps1'
        arguments: '$(workspaceRoot) $(ispwApplication) $(sonarProjectName) $(sonarSources)'


Job checkQualityGate (conditional)

This job is executed based on the condition, that the job sonar ran successfully.

  - job: checkQualityGate
    displayName: Check Quality Gate
    dependsOn: sonar
    steps:

 
Execute PowerShell script Sonar_Check_Quality_Gate-ps1 to query the status of the Sonar quality gate.

    - task: PowerShell@2
      displayName: Check Sonar Quality Gate
      inputs:
        filePath: '$(agentScriptsPath)\Sonar_Check_Quality_Gate.ps1'
        arguments: '$(sonarServer) $(sonarProjectName) $(sonarAuthorization)'


Job triggerRelease (conditional)

This job is executed based on the condition, that the job checkQualityGate ran successfully, and will trigger the release pipeline.

  - job: triggerRelease
    displayName: Trigger Release Pipeline
    dependsOn:
    - checkQualityGate
    condition: succeeded('checkQualityGate')
    steps:

Again, determine the QA level based on the DEV level.

Warning

Important

Per default variables are not 'visible' across job boundaries. Therefore, we need to set the variable again for this job.

    - task: PowerShell@2
      displayName: Determine ISPW Target Level
      name: setTargetLevel
      inputs:
        targetType: 'inline'
        script: |
          $ispwTargetLevel = 'QA' + '$(ispwLevel)'.Substring('$(ispwLevel)'.Length - 1, 1)
          Write-Host 'Determined Level ' $ispwTargetLevel
          echo "##vso[task.setvariable variable=ispwTargetLevel]$ispwTargetLevel"

Execute PowerShell script Azure_Trigger_Release.ps1 to trigger an Azure DevOps release pipeline(##create-a-release-pipeline).

    - task: PowerShell@2
      displayName: Trigger Release
      inputs:
        filePath: '$(agentScriptsPath)\Azure_Trigger_Release.ps1'
        arguments: '$(azureRestAddress) $(azureOrganization) $(System.TeamProject) "$(azureRestAuthorization)" $(ispwApplication) $(ispwContainerName) $(ispwContainerType) $(ispwTargetLevel) $(releaseDefinitionId)'

Job regressAssigment (conditional)

This job is executed based on the condition, that the job checkQualityGate failed, and will regress the Code Pipeline assignment.

  - job: regressAssignment
    dependsOn:
    - checkQualityGate
    condition: failed('checkQualityGate')
    steps:

Again, determine the QA level based on the DEV level.

Warning

Important

Per default variables are not 'visible' across job boundaries. Therefore, we need to set the variable again for this job.

    - task: PowerShell@2
      displayName: Determine ISPW Target Level
      name: setTargetLevel
      inputs:
        targetType: 'inline'
        script: |
          $ispwTargetLevel = 'QA' + '$(ispwLevel)'.Substring('$(ispwLevel)'.Length - 1, 1)
          Write-Host 'Determined Level ' $ispwTargetLevel
          echo "##vso[task.setvariable variable=ispwTargetLevel]$ispwTargetLevel"

Execute PowerShell script ISPW_Operations-ps1to regress the Code Pipeline assignment

    - task: PowerShell@2
      displayName: Regress Assignment
      inputs:
        filePath: '$(agentScriptsPath)\ISPW_Operations.ps1'
        arguments: 'ContainerOperation $(cesUri) $(ispwConfig) assignments regress $(ispwContainerName) $(ispwTargetLevel) $(cesToken) FTSDEMO $(ispwApplication) $(ispwServer)'

 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC AMI DevX Mainframe DevOps