正如circleCI开发人员所知,circleCi通知会被贬低,转而支持ORB。
我需要启用松弛通知,并且已经开始使用circleci/slack@3.4.2
包
我的circleCI config.yml文件包含x个命令,如下所示:
commands:
build-mu-plugins:
steps:
- run:
name: Clone mu-plugins
command: |
git clone git@github.com:Automattic/vip-go-mu-plugins.git mu-plugins && cd mu-plugins && git submodule update --init --recursive && cd ..
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-mu-plugins'
webhook: $SLACK_WEBHOOK
build-base-composer:
steps:
- add_ssh_keys:
fingerprints:
# CircleCI Fingerprint in newsuk repo
- fxxxxxxxx99:c5:2c
- run:
name: Install composer inside root directory
command: composer install -n
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-base-composer'
webhook: $SLACK_WEBHOOK
build-wp-simple-saml:
steps:
- run:
name: Install composer packages for wp-simple-saml
command: composer install --no-dev --working-dir=plugins/wp-simple-saml/ -n --prefer-dist
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-wp-simple-saml'
webhook: $SLACK_WEBHOOK
但是,在原理上,由于每个- slack/status
几乎相同,我怀疑是否有在每个命令中配置ORB的更有效的方法
能
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-base-composer'
webhook: $SLACK_WEBHOOK
放入一个参数或类似的东西中,这样我就可以简单地重复操作,而不需要在每个命令中定义所有ORB
也许是像这样的
**orb-message** <<
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-base-composer'
webhook: $SLACK_WEBHOOK
commands:
build-mu-plugins:
steps:
- run:
name: Clone mu-plugins
command: |
git clone git@github.com:Automattic/vip-go-mu-plugins.git mu-plugins && cd mu-plugins && git submodule update --init --recursive && cd ..
# - ORB Message
- **orb-message**
我是circleCI的新手,但很难找到有关这方面的文档
我的完整circleCI文件如下:
version: 2.1
orbs:
slack: circleci/slack@3.4.2
commands:
build-mu-plugins:
steps:
- run:
name: Clone mu-plugins
command: |
git clone git@github.com:Automattic/vip-go-mu-plugins.git mu-plugins && cd mu-plugins && git submodule update --init --recursive && cd ..
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-mu-plugins'
webhook: $SLACK_WEBHOOK
build-base-composer:
steps:
- add_ssh_keys:
fingerprints:
# CircleCI Fingerprint in newsuk repo
- xxxxxxxxxx
- run:
name: Install composer inside root directory
command: composer install -n
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-base-composer'
webhook: $SLACK_WEBHOOK
build-wp-simple-saml:
steps:
- run:
name: Install composer packages for wp-simple-saml
command: composer install --no-dev --working-dir=plugins/wp-simple-saml/ -n --prefer-dist
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-wp-simple-saml'
webhook: $SLACK_WEBHOOK
build-academy-composer:
steps:
- run:
name: Install composer inside academy theme
command: |
composer install --working-dir=themes/newsacademy/ -o -n
composer --working-dir=themes/newsacademy/ php:lint
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-academy-composer'
webhook: $SLACK_WEBHOOK
build-nuk-newsuk-okta-plugin:
steps:
- run:
name: Install composer packages for News UK OKTA Plugin
command: composer install --no-dev --working-dir=plugins/nuk-wp-okta-plugin/ -n --prefer-dist --optimize-autoloader
- run:
name: Lint nuk-wp-okta-plugin
command: composer php:lint-okta
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-nuk-newsuk-okta-plugin'
webhook: $SLACK_WEBHOOK
build-plugin-loader:
steps:
- run:
name: Install composer packages for News UK OKTA Plugin
command: composer php:lint-plugin-loader
# - ORB Message
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME your Job $CIRCLE_JOB failed build-plugin-loader !'
webhook: $SLACK_WEBHOOK
jobs:
build:
docker:
- image: circleci/php:7.3-node-browsers
steps:
- checkout
- build-mu-plugins
- build-base-composer
- build-nuk-newsuk-okta-plugin
- build-plugin-loader
- build-academy-composer
- build-wp-simple-saml
#- run: npm install
#- run: npm run build
#- run: vendor/bin/phpunit
# TODO: Configure build steps here ^^^^^
- persist_to_workspace:
root: ./
paths:
- ./
deploy:
docker:
- image: circleci/php:7.3-node-browsers
steps:
- attach_workspace:
at: ./
- checkout
- add_ssh_keys:
fingerprints:
# CircleCI Deploy Fingerprint in wpcomvip repo
- xxxxxxxxxx
- run:
name: Deploy -built branch to github
command: bash <(curl -s "https://raw.githubusercontent.com/Automattic/vip-go-build/master/deploy.sh")
- slack/status:
fail_only: false
#channel: 'CS70KQ92N' use this if you want to deliver to a different channel other than the hook
only_for_branches: master
success_message: ':ok_hand: JOB $CIRCLE_JOB has been successful deploying to production'
failure_message: ':red_circle: JOB $CIRCLE_JOB has failed deploying to production!'
webhook: $SLACK_WEBHOOK
# Sync job runs every time to ensure we keep the News UK repository in sync with the VIP repo
sync:
docker:
- image: cimg/base:2020.01
steps:
# Run standard checkout to get the appropriate SSH keys installed, but then remove afterwards
- checkout:
path: checkout-tmp
- run:
name: Cleanup temporary checkout
command: rm -rf checkout-tmp
# Do the actual mirror & sync
- run:
name: Mirror clone from VIP repository
command: git clone --mirror ${CIRCLE_REPOSITORY_URL} readonly
- run:
name: Remove GitHub PR references
# https://stackoverflow.com/questions/37985275/how-can-i-exclude-pull-requests-from-git-mirror-clone/39764408#39764408
command: cd readonly && git show-ref | cut -d ' ' -f2 | (grep 'pull' || true) | xargs -r -L1 git update-ref -d
- add_ssh_keys:
fingerprints:
# CircleCI Sync Fingerprint in newsuk repo
- xxxxxxxxxxx
- run:
name: Add the News UK repository as the readonly remote
command: cd readonly && git remote add readonly git@github.com:newsuk/nuk-newsuk-wp.git
- run:
name: Push mirror to News UK (readonly) repository
command: cd readonly && git push --mirror readonly
workflows:
version: 2
sync:
jobs:
- sync
build_deploy:
jobs:
- build:
filters:
branches:
only:
- staging
- develop
- master
- deploy:
requires:
- build
filters:
branches:
only:
- master
- staging
- develop
发布于 2020-08-24 22:42:53
好的,我猜到了
我可以在一个命令中运行一个命令,这样定义如下
commands:
orb-message:
steps:
- slack/status:
fail_only: true
only_for_branches: develop,staging,master
failure_message: ':red_circle: $CIRCLE_USERNAME Job $CIRCLE_BRANCH failed'
webhook: $SLACK_WEBHOOK
build-mu-plugins:
steps:
- run:
name: Clone mu-plugins
command: |
git clone git@github.com:Automattic/vip-go-mu-plugins.git mu-plugins && cd mu-plugins && git submodule update --init --recursive && cd ..
# - ORB Message
- orb-message
https://stackoverflow.com/questions/63560810
复制相似问题