cloudfoundry-community / slack-notification-resource

Concourse CI resource for sending notifications to Slack.
MIT License
75 stars 81 forks source link

Concourse To Slack Notification - Not Picking up text_file #54

Closed akamalov closed 6 years ago

akamalov commented 6 years ago

I am trying to create Concourse (3.14.0) pipeline which using latest slack-notification-resource notifies a slack channel if the job has successfully completed or not. While pipeline notification does go through, it only posts text message supplied in the pipeline, but does not read from a directory where text messages are kept. I keep notify_message directory under repository root directory, with pre-configured messages.

Here is my pipeline:

jobs:
- name: export-om-installation
  serial: true
  plan:
  - aggregate:
    - get: bbr-pipeline-tasks-repo
      trigger: true
  - task: export-om-installation
    file: bbr-pipeline-tasks-repo/tasks/export-om-installation/task.yml
    params:
      SKIP_SSL_VALIDATION: ((skip-ssl-validation))
      OPSMAN_URL: ((opsman-url))
      OPSMAN_USERNAME: ((opsman-username))
      OPSMAN_PASSWORD: ((opsman-password))
  - put: om-backup-artifact
    params:
      file: om-installation/installation.zip
  on_success:
    put: slack-alert
    params:
      channel: '#cloudeng'
      text: "Task: Export OM Installation is Successful!"
      text_file: notify_message/success-export-om-installation
      silent: false
  on_failure:
    put: slack-alert
    params:
      channel: '#cloudeng'
      text: "Task: Export OM Installation has Failed!"
      text_file: notify_message/failure-export-om-installation
      silent: false

- name: bbr-backup-ert
  serial: true
  plan:
  - aggregate:
    - get: bbr-pipeline-tasks-repo
      trigger: true
    - get: bbr-release
      trigger: true
  - task: extract-binary
    tags:
    - ((concourse-worker-tag))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: cloudfoundrylondon/bbr-pipeline
          tag: release-candidate
      inputs:
      - name: bbr-release
      outputs:
      - name: binary
      run:
        path: sh
        args:
        - -c
        - |
          tar -xvf bbr-release/bbr*.tar
          cp releases/bbr binary/
  - task: bbr-backup-ert
    tags:
    - ((concourse-worker-tag))
    file: bbr-pipeline-tasks-repo/tasks/bbr-backup-ert/task.yml
    params:
      SKIP_SSL_VALIDATION: ((skip-ssl-validation))
      OPSMAN_URL: ((opsman-url))
      OPSMAN_USERNAME: ((opsman-username))
      OPSMAN_PASSWORD: ((opsman-password))
  - put: ert-backup-bucket
    params:
      file: ert-backup-artifact/ert-backup.tar
  on_success:
    put: slack-alert
    params:
      channel: '#cloudeng'
      text: "Task: BBR Backup ERT is Successful!"
      text_file: notify_message/success-bbr-backup-ert
      silent: false
  on_failure:
    put: slack-alert
    params:
      channel: '#cloudeng'
      text: "Task: BBR Backup ERT has FAILED!"
      text_file: notify_message/failure-bbr-backup-ert
      silent: false

- name: bbr-backup-director
  serial: true
  plan:
  - aggregate:
    - get: bbr-pipeline-tasks-repo
      trigger: true
    - get: bbr-release
      trigger: true
  - task: extract-binary
    tags:
    - ((concourse-worker-tag))
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: cloudfoundrylondon/bbr-pipeline
          tag: release-candidate
      inputs:
      - name: bbr-release
      outputs:
      - name: binary
      run:
        path: sh
        args:
        - -c
        - |
          tar -xvf bbr-release/bbr*.tar
          cp releases/bbr binary/

  - task: bbr-backup-director
    tags:
    - ((concourse-worker-tag))
    file: bbr-pipeline-tasks-repo/tasks/bbr-backup-director/task.yml
    params:
      SKIP_SSL_VALIDATION: ((skip-ssl-validation))
      OPSMAN_URL: ((opsman-url))
      OPSMAN_USERNAME: ((opsman-username))
      OPSMAN_PASSWORD: ((opsman-password))
  - put: director-backup-bucket
    params:
      file: director-backup-artifact/director-backup.tar
  on_success:
    put: slack-alert
    params:
      channel: '#cloudeng'
      text: "Task: BBR Backup Director - Upload To Object-Store Successful!"
      text_file: notify_message/success-bbr-backup-director
      silent: false
  on_failure:
    put: slack-alert
    params:
      channel: '#cloudeng'
      text: "Task: BBR Backup Director - Upload To Object-Store has FAILED!"
      text_file: notify_message/failure-bbr-backup-director
      silent: false

resource_types:
- name: pivnet
  type: docker-image
  source:
    repository: pivotalcf/pivnet-resource
    tag: latest-final
- name: slack-notification
  type: docker-image
  source:
    repository: cfcommunity/slack-notification-resource

resources:

- name: slack-alert
  type: slack-notification
  source:
    url: ((slack-webhook))
- name: bbr-pipeline-tasks-repo
  type: git
  source:
    uri: https://github.com/pivotal-cf/bbr-pcf-pipeline-tasks.git
    branch: master
- name: om-backup-artifact
  type: s3
  source:
    bucket: ((backup-artifact-bucket))
    region_name: ((storage-region))
    endpoint: ((storage-endpoint))
    access_key_id: ((storage-access-key-id))
    secret_access_key: ((storage-secret-access-key))
    versioned_file: installation.zip
    use_v2_signing: ((storage-use-v2-signing))
    disable_ssl: ((disable_ssl))
- name: ert-backup-bucket
  type: s3
  source:
    bucket: ((backup-artifact-bucket))
    region_name: ((storage-region))
    endpoint: ((storage-endpoint))
    access_key_id: ((storage-access-key-id))
    secret_access_key: ((storage-secret-access-key))
    versioned_file: ert-backup.tar
    use_v2_signing: ((storage-use-v2-signing))
    disable_ssl: ((disable_ssl))
- name: director-backup-bucket
  type: s3
  source:
    bucket: ((backup-artifact-bucket))
    region_name: ((storage-region))
    endpoint: ((storage-endpoint))
    access_key_id: ((storage-access-key-id))
    secret_access_key: ((storage-secret-access-key))
    versioned_file: director-backup.tar
    use_v2_signing: ((storage-use-v2-signing))
    disable_ssl: ((disable_ssl))
- name: bbr-release
  type: pivnet
  source:
    api_token: ((pivnet-api-token))
    product_slug: p-bosh-backup-and-restore

So far, I only get the text - example: "Task: Export OM Installation is Successful!", the same goes for BOSH-ERT backup. That's it. No body.

My sample message in the text file is

FILE: notify_message/success-export-om-installation

"Pipeline job successfully completed. Please navigate to https://xxxxxxx:8080 for your complete job status"

So far, what I am getting is this:

image

What should I do to swtich from text to text_file? I think for some reason pipeline is not picking up notify_message/<message_file>. Any pointers? What is it I am doing wrong here?

Thanks again!!

jhunt commented 6 years ago

Have you tried setting:

  # ...
  params:
    metadata: yes
    payload_in_metadata: yes

on your on_{success,failure} stanzas to get more debugging information out of the resource?

akamalov commented 6 years ago

Thanks for your reply, @jhunt . Here is my pipeline:

jobs:
- name: export-om-installation
  serial: true
  plan:
  - aggregate:
    - get: bbr-pipeline-tasks-repo
      trigger: true
  - task: export-om-installation
    file: bbr-pipeline-tasks-repo/tasks/export-om-installation/task.yml
    params:
      SKIP_SSL_VALIDATION: ((skip-ssl-validation))
      OPSMAN_URL: ((opsman-url))
      OPSMAN_USERNAME: ((opsman-username))
      OPSMAN_PASSWORD: ((opsman-password))
  - put: om-backup-artifact
    params:
      file: om-installation/installation.zip
      inputs:
        - name: export-om-installation
      outputs:
        - name: notify_message
  on_success:
    put: slack-alert
    params:
      channel: '#cloudeng'
      metadata: yes
      payload_in_metdata: yes
      text_file: notify_message/success-export-om-installation
      silent: false
  on_failure:
    put: slack-alert
    params:
      channel: '#cloudeng'
      metadata: yes
      text_file: notify_message/failure-export-om-installation
      silent: false

resource_types:
- name: pivnet
  type: docker-image
  source:
    repository: pivotalcf/pivnet-resource
    tag: latest-final
- name: slack-notification
  type: docker-image
  source:
    repository: cfcommunity/slack-notification-resource

resources:

- name: slack-alert
  type: slack-notification
  source:
    url: ((slack-webhook))
- name: bbr-pipeline-tasks-repo
  type: git
  source:
    uri: https://github.com/pivotal-cf/bbr-pcf-pipeline-tasks.git
    branch: master
- name: om-backup-artifact
  type: s3
  source:
    bucket: ((backup-artifact-bucket))
    region_name: ((storage-region))
    endpoint: ((storage-endpoint))
    access_key_id: ((storage-access-key-id))
    secret_access_key: ((storage-secret-access-key))
    versioned_file: installation.zip
    use_v2_signing: ((storage-use-v2-signing))
    disable_ssl: ((disable_ssl))

However, unfortunately it is still showing in Slack that no notification provided.

Alex

akamalov commented 6 years ago

Found better slack-notification-resource: https://github.com/arbourd/concourse-slack-alert-resource

jhunt commented 6 years ago

:+1:

mattgodbolt commented 4 years ago

This is still a bug in this repo though...