Slack 通知大厅 - 未接收 text_file

Concourse To Slack Notification - Not Picking up text_file

我正在尝试创建 Concourse (3.14.0) 管道,它会在作业是否成功完成时通知松弛通道。虽然管道通知确实通过,但它只发布管道中提供的文本消息,但不会从保存文本消息的目录中读取。我将 notify_message 目录保存在存储库根目录下,其中包含预先配置的消息。

这是我的管道:

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

到目前为止,我只得到文本 - 例如:“Task: Export OM Installation is Successful!”。而已。没有尸体。

我在文本文件中的示例消息是

文件:notify_message/success-export-om-installation

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

有什么指点吗?我这里做错了什么?

再次感谢!!

您必须将 $TEXT_FILE_CONTENT 放在文本参数中 像这样:

- put: slack-alert
    params:
      channel: '#cloudeng'
      text_file: results/message.txt
      text: |
              Task: Export OM Installation is Successful!
              Result: $TEXT_FILE_CONTENT 

[另一个更好的资源]

我建议您查找此资源,而不是编写您自己的短信文件。

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

它有预先格式化的消息,实施起来更容易。