Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Now Change Management - Transmitting Change Request Number as an Output Variable Between Stages. #1207

Open
hmtmh opened this issue Nov 16, 2023 · 2 comments

Comments

@hmtmh
Copy link

hmtmh commented Nov 16, 2023

Is it possible to designate "Change_Request_Number" as an output variable in a YAML pipeline, similar to the approach used in a classic release pipeline?

This is how it is being done in classic release pipeline.
image

We aim to use the Change Request Number in a subsequent stage to perform an update on the corresponding change request.

image

@aczarkowski
Copy link

aczarkowski commented Dec 12, 2023

I have been looking at the same thing. You don't need to do that at all. UpdateServiceNowChangeRequest@2 task will query for the change request number first if not provided. It will get the change request number created by the approval gate (uses some correlation id behind the scenes to query for it).
If you want to know the value of change request then the same UpdateServiceNowChangeRequest@2 will create output variable with the same name (CHANGE_REQUEST_NUMBER) which you can then easily retrieve in the next job or stage. See my example:

  - job: update_change_request
    dependsOn: 
      - calculate_parameters
    pool: server
    variables:
      PlannedStartDate: $[ dependencies.calculate_parameters.outputs['calculate_parameters.plannedStartDate'] ]
      PlannedEndDate: $[ dependencies.calculate_parameters.outputs['calculate_parameters.plannedEndDate'] ]
    steps:
      - task: UpdateServiceNowChangeRequest@2
        name: update_change_request
        inputs:
          ServiceNowConnection: 'ServiceNowTestBasicAuth'
          WorkNotes: 'This is a test'
          otherParameters: |
            {
              "u_justification": "Test",
              "u_risk_impact_analysis": "Test",
              "u_implementation_plan": "Test",
              "u_backout_plan": "Test",
              "u_test_plan": "Test"
            }


  - job: display_change_request
    dependsOn: 
      - update_change_request
    pool:
      vmImage: 'ubuntu-latest'
    variables:
      ChangeRequestNumber: $[ dependencies.update_change_request.outputs['update_change_request.CHANGE_REQUEST_NUMBER'] ]
    steps:
      - task: PowerShell@2
        inputs:
          targetType: 'inline'
          script: |
            Write-Host "Change Request Number: $(ChangeRequestNumber)"
      - bash: echo "##vso[task.setvariable variable=CHANGE_REQUEST_NUMBER;isOutput=true]$(ChangeRequestNumber)"
        name: set_output_variable

@bharathkumarkappala
Copy link

@aczarkowski Thanks for the yaml it helped me big time, I was really excited after finding your yaml. I have another question

I am using environment approvals and check at the prod deploy stage to check if the change ticket created during the dev stage is in a certain status now my question is how do I pass the change record number dynamically in the environment at the approvals and checks so that the valdation can be done on the exact change which was created during the dev stage.

I am a beginer in yaml and ado so I would really appriciate all you inputs here thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants