闲置通知的场所-不接收text_file

时间:2018-06-25 14:58:48

标签: concourse

我正在尝试创建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

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

再次感谢!

1 个答案:

答案 0 :(得分:2)

您必须在文本参数内放置 $ 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

它具有预格式化的消息,实现起来更加容易。