newman-action icon indicating copy to clipboard operation
newman-action copied to clipboard

how get error from test step to send it in slack?

Open kamil-nawrotkiewicz opened this issue 3 years ago • 0 comments

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

kamil-nawrotkiewicz avatar Mar 24 '23 12:03 kamil-nawrotkiewicz