Inclusion of Servicenow change request state as condition in pipeline prior to prod deployment approval

Hi All

We are looking for a way to include the Change Request State from ServiceNow as a condition in gitlab pipeline prior to Production deployment.

For example An Rest API call to ServiceNow to query change request state and say if state is “implement” then Gitlab should proceed for Prod deployment, Basically this should act as a conditional gate for deployment.

Anyone implemented this in your projects or share your experience on this can be implemented in pipeline. What is the best way to implement this using rules or something else? Any leads will be greatly helpful

Hi,

I didn’t implement anything like that, but if you have access to REST API almost anything is possible with a custom script.

If we are talking a simple “yes/no” “true/false” gate, e.g. if yes → proceed, if no → don’t proceed, it should be quite simple.

You can make a script (python/bash/go/literally whatever language) that calls the API and depending on the result it returns either 0 (if it should proceed) or something else (if it should not proceed). GitLab pipelines by default do not proceed further when a job has failed. So the most basic setup would be like this:

stages:
- check
- deploy

check service:
  stage: check
  script:
    - # call api and evaluate the result; make sure it fails with exit > 0 when it shouldn't go further

deploy to prod:
  stage: deploy
  script: 
    - echo "Deploying to prod"

Hope this gives you enough inspiration for start! :slight_smile: