newman-action
newman-action copied to clipboard
how get error from test step to send it in slack?
Each of echo error return null or empty string. How get error output from apiTestInstance?
api-test-instance:
runs-on: self-hosted
steps:
- uses: rlespinasse/github-slug-action@v4
with:
short-length: 5
- uses: actions/checkout@master
- name: Test api postman
id: apiTestInstance
uses: matt-ball/newman-action@master
with:
apiKey: ${{ secrets.POSTMAN_API_KEY }}
collection: "postman/collections/collection.json"
environment: "xxx"
- name: Echo Error
if: failure()
run: |
echo "apiTestInstance failed with the following error message:"
echo "${{ steps.apiTestInstance.log }}"
- name: Echo Error 2
if: failure()
run: |
echo "apiTestInstance failed with the following error message:"
echo "${{ steps.apiTestInstance.outputs['newman-error'] }}"
- name: Echo Error 3
if: failure()
run: |
echo "apiTestInstance failed with the following error message:"
echo "${{ steps.apiTestInstance.outputs.stdout }}"
- name: Echo Error 4
if: failure()
run: |
echo "apiTestInstance failed with the following error message:"
echo "${{ steps.apiTestInstance.outputs.newman-error }}"
- name: Echo Error 5
if: failure()
run: |
echo "apiTestInstance failed with the following error message:"
echo "${{ steps.apiTestInstance.outputs }}"
- name: Echo Error 6
if: failure()
run: |
echo "apiTestInstance failed with the following error message:"
echo "${{ toJson(steps.apiTestInstance.outputs) }}"
- name: Send Slack Message
if: failure()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "Errors from tests api postman",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Newman test failed: ${{ steps.apiTestInstance.outputs['newman-error'] }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_POSTMAN_NOTIFICATION_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK