Skip to content

Commit

Permalink
#402: link to CR from the step fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
lrochette committed Oct 13, 2021
1 parent 51f3598 commit 5fffb6e
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions incubating/service-now/step.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,24 @@ metadata:
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: {"work_notes":"Test pass rate: ${{_TEST_RATE}}"}
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: {"close_note":"Closed automatically by Codefresh build ${{CF_BUILD_ID}}"}
CR_DATA: {"work_notes":"Closed automatically by Codefresh build ${{CF_BUILD_ID}}"}

spec:
arguments: |-
Expand Down Expand Up @@ -147,16 +149,6 @@ spec:
}
}
stepsTemplate: |-
info:
name: debug step
image: alpine
environment:
[[ range $key, $val := .Arguments ]]
- '[[ $key ]]=[[ $val ]]'
[[- end ]]
commands:
- echo "ACTION- $CR_ACTION" || true
- echo "DEBUG- $DEBUG" || true
[[ if eq .Arguments.CR_ACTION "closeCR" ]]
closeCR:
name: Close a ServiceNow Change Request
Expand All @@ -180,7 +172,7 @@ spec:
- ACTION=updatecr
[[ end ]]
[[ if eq .Arguments.CR_ACTION "createCR" ]]
createCR:
createcr:
name: Create a ServiceNow Change Request
title: Use REST API to create a CR
image: lrochette/service-now:1.1.0
Expand All @@ -189,17 +181,14 @@ spec:
- '[[ $key ]]=[[ $val ]]'
[[- end ]]
- ACTION=createcr
createAnnotation:
annotation:
name: Assign CR_NUMBER as annotation
image: codefresh/cli
commands:
- |
codefresh create annotation workflow ${{CF_BUILD_ID}} CR_NUMBER=${{CR_NUMBER}}
codefresh create annotation workflow ${{CF_BUILD_ID}} CR_SYSID=${{CR_SYSID}}
codefresh create annotation workflow ${{CF_BUILD_ID}} CR_URL='[[.Arguments.SN_INSTANCE]]/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3D${{CR_SYSID}}'
export createCR_CF_OUTPUT_URL='[[.Arguments.SN_INSTANCE]]/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3D${{CR_SYSID}}'
# echo $createAnnotation_CF_OUTPUT_URL
# cf_export createAnnotation_CF_OUTPUT_URL
cf_export annotation_CF_OUTPUT_URL="[[.Arguments.SN_INSTANCE]]/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3D$CR_SYSID"
callback:
name: invoke scripted REST API to have ServiceNow callback Codefresh when CR is approved/rejected
title: ServiceNow callback setup
Expand Down

0 comments on commit 5fffb6e

Please sign in to comment.