Codefresh Steps: Reusable Code for Common Operations
This page provides code you can use to perform common operations in the Codefresh CI/CD platform.
4.7K

service-now service-now

Integration with ServiceNow Change Management

arguments

  • CR_ACTION - Action to execute: createCR or closeCR
  • CR_CLOSE_CODE - Close code for the closeCR action: successful, successful_issues or unsuccessful
  • CR_CLOSE_NOTES - Close notes for the closeCR action: successful, successful_issues or unsuccessful
  • CR_CONFLICT_POLICY - Policy to exectute in case of schedule conflict. Accepted values are ignore (no check is done), wait (pipeline will wait until the conflict is resolved) or reject ServiceNow flow returns a deny answer
  • CR_DATA - The body to create the CR. Need to include all the fields required for your Change Management implementation.
  • DEBUG - Obsolete - Set LOG_LEVEL to debug for backward compatibility
  • LOG_LEVEL - OPTIONAL - set the log level, e.g. 'debug', 'info', 'warn', 'error', 'critical' (default 'error')
  • SN_IMAGE - The ServiceNow container image registry/image for the step.
  • SN_IMAGE_VERSION - Version of the ServiceNow image to use, Docker image tag.
  • SN_INSTANCE - The URL to your Service-now instance aka https://instance.service-now.com
  • SN_NAMESPACE - The endpoint namespace to call if using a different one. The system will call $SN_INSTANCE/api/$namespace/codefresh/callback
  • SN_PASSWORD - The password associated to the username to log into the instance
  • SN_USER - The username to log into the instance
  • TOKEN - The Codefresh API token to allow ServiceNow to approve/deny the pipeline

returns

  • CR_NUMBER - The number of the CR created.
  • CR_SYSID - The sysid of the CR created
    createChange:
  title: Create a Service Now Change Request
  type: service-now
  stage: deploy
  arguments:
    CR_ACTION: createCR
    TOKEN: '${CF_API_TOKEN}'
    SN_INSTANCE: 'https://instance.service-now.com'
    SN_USER: '${{SN_USER}}'
    SN_PASSWORD: '${{SN_PASSWORD}}'
    CR_CONFLICT_POLICY: reject
    CR_DATA: >-
      {"short_description":"This is a Change Request created by
      Codefresh","description":"long description for Codefresh build
      ${{CF_BUILD_ID}}","justification":"because our app is awesome"}

  
    modifyCR:
  title: Modify the CR
  type: service-now
  stage: deploy
  arguments:
    CR_ACTION: closeCR
    CR_SYSID: '${{CR_SYSID}}'
    SN_INSTANCE: 'https://instance.service-now.com'
    SN_USER: '${{SN_USER}}'
    SN_PASSWORD: '${{SN_PASSWORD}}'
    CR_DATA: >-
      {"test_plan":"We ran all the test in the awesome test suite. Test pass
      rate: ${{TEST_RATE}}"}

  
    closeCR:
  title: Close the CR
  type: service-now
  stage: cleaning
  arguments:
    CR_ACTION: closeCR
    CR_SYSID: '${{CR_SYSID}}'
    SN_INSTANCE: 'https://instance.service-now.com'
    SN_USER: '${{SN_USER}}'
    SN_PASSWORD: '${{SN_PASSWORD}}'
    CR_CLOSE_CODE: successful
    CR_CLOSE_NOTES: 'CR closed by Codefresh build ${{CF_BUILD_ID}}'
    CR_DATA: '{"work_notes":"Closed automatically by Codefresh build ${{CF_BUILD_ID}}"}'

  
github.com
Laurent Rochette
Sep 22, 2023