profile
viewpoint
Kyle T KyleTryon @circleci Philadelphia https://techsquidtv.com Sometimes I learn, sometimes I teach. Partner Integration Engineer @circleci @youtube: http://techsquid.tv

circleci/CircleCI-Training-Koans 15

A set of puzzles to be completed to help familiarize yourself with CircleCI

CircleCI-Public/Orb-Project-Template 7

A starter template for orb projects. Build, test, and publish orbs automatically on CircleCI.

CircleCI-Public/hacktoberfest 6

Starting in 2019 CircleCI will now join in the annual tradition of Hacktoberfest! Check here for our current Hacktoberfest landing page and learn how you can participate.

CircleCI-Public/aws-code-deploy-orb 5

Easily deploy applications to AWS CodeDeploy on CircleCI with the aws-code-deploy orb

CircleCI-Public/aws-s3-orb 4

Integrate Amazon AWS S3 with your CircleCI CI/CD pipeline easily with the aws-s3 orb.

CircleCI-Public/gcp-cloud-run-orb 2

Deploy to Google Cloud Run using this orb from CircleCI

CircleCI-Public/Orb-Policies 2

Orb standards and best practices

CircleCI-Public/gcp-cloud-run-sample-project 1

Sample project for CircleCI utilizing the GCP Cloud Run orb to deploy to the Cloud Run managed service.

CircleCI-Public/gradle-orb 1

Simplify common tasks for building and testing Java projects using Gradle on CircleCI using this orb.

issue closedCircleCI-Public/slack-orb

Slack notification error on build failure only delivered when event set to always

Orb version: 4.1.2

Slack notification snippet from config.yml:

jobs:
  build-and-test:
    executor: python/default
    steps:
      - checkout
      - python/install-packages:
          pkg-manager: poetry
      - run:
          command: |
            poetry run pytest test/test.py
          name: Test it
      - slack/notify:
          branch_pattern: develop,master
          event: fail
          template: basic_fail_1

What happened:

On CircleCI build failure, Slack notification only appears when event: always is set, and does not appear on build failure when event: fail is set. The following error appears in CircleCI when event: fail and build fails:

Screen Shot 2020-11-26 at 4 09 46 PM

Expected behavior:

On CircleCI build failure, Slack notification of build failure should appear when event: fail is set.

It appears as though the issue may be fixed in https://github.com/CircleCI-Public/slack-orb/commit/d362258c47bcf02a2a62b6da56b95111233c48d6 <!--- what should happen, ideally? -->

Additional Information:

closed time in 12 hours

adamhartley

issue commentCircleCI-Public/slack-orb

Slack notification error on build failure only delivered when event set to always

Confirmed issue has been fixed by https://github.com/CircleCI-Public/slack-orb/commit/d362258c47bcf02a2a62b6da56b95111233c48d6 in 4.1.3

adamhartley

comment created time in 12 hours

created tagCircleCI-Public/slack-orb

tagv4.1.3

Create custom Slack notifications for CircleCI job statuses

created time in 21 hours

issue openedCircleCI-Public/slack-orb

Slack notification on failure only delivered when event set to always

Orb version: 4.1.2

Slack notification snippet from config.yml:

      - slack/notify:
          branch_pattern: develop,master
          event: fail
          template: basic_fail_1

What happened:

On CircleCI build failure, Slack notification only appears when event: always is set, and does not appear on build failure when event: fail is set.

Expected behavior:

On CircleCI build failure, Slack notification of build failure should appear when event: fail is set. <!--- what should happen, ideally? -->

Additional Information:

created time in a day

issue commentCircleCI-Public/slack-orb

Impossible to filter on empty tag name.

hey @rogersd how about trying something like that:

branch_pattern: ""
tag_pattern: [0-9]+\.[0-9]+\.[0-9]+(-.+)?

it's supposed to send notification on matched tags only and disregard branched

❯ echo "12.12.12-qa1" | grep -Eq "^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$" && echo "send notification"
send notification
❯ echo "12.12.12-rc2" | grep -Eq "^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$" && echo "send notification"
send notification
❯ echo "12.12.12" | grep -Eq "^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$" && echo "send notification"
send notification
❯ echo "12.12" | grep -Eq "^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$" && echo 'send notification'
# no send

let me know if that works

rogersd

comment created time in 2 days

issue commentCircleCI-Public/slack-orb

Impossible to filter on empty tag name.

Just to explain my use case a bit more, let's say I have my master branch and four environments. The deployment can be triggered in one of four ways:

Automatically deployed to the dev environment on merge to master. (No tag.) Deployed to QA with a #.#.#-qa# tag. Deployed to staging with a #.#.#-rc# tag. Deployed to production with a #.#.# tag.

So, in the first case, there won't be a tag, but in all cases the branch name will be the same (master).

What I'd like is to not have the first case send a notification. The problem is that I can't filter on the tag in the first case because the tag is empty. I had tried passing a regex of [0-9]+\.[0-9]+\.[0-9].* as the tag_pattern, but the notification went through anyway.

rogersd

comment created time in 2 days

delete branch CircleCI-Public/slack-orb

delete branch : shouldpost-fix

delete time in 3 days

push eventCircleCI-Public/slack-orb

Gabriel Simmer

commit sha d362258c47bcf02a2a62b6da56b95111233c48d6

[semver:patch] Fix order of operations with shouldpost. (#215)

view details

push time in 3 days

create barnchCircleCI-Public/slack-orb

branch : shouldpost-fix

created branch time in 3 days

Pull request review commentCircleCI-Public/slack-orb

[semver:patch] Decide earlier whether to post message

 CheckEnvVars() {     fi } +ShouldPost() {+    if [ "$CCI_STATUS" = "$SLACK_PARAM_EVENT" ] || [ "$SLACK_PARAM_EVENT" = "always" ]; then+        # In the event the Slack notification would be sent, first ensure it is allowed to trigger+        # on this branch or this tag.+        FilterBy "$SLACK_PARAM_BRANCHPATTERN" "$CIRCLE_BRANCH"+        FilterBy "$SLACK_PARAM_TAGPATTERN" "$CIRCLE_TAG"++        echo "Posting Status"+    else +        # dont send message.+        echo "NO SLACK ALERT"+        echo+        echo "This command is set to send an alert on: $SLACK_PARAM_EVENT"+        echo "Current status: ${CCI_STATUS}"+        exit 0+    fi+}+ # Will not run if sourced from another script. # This is done so this script may be tested. ORB_TEST_ENV="bats-core" if [ "${0#*$ORB_TEST_ENV}" = "$0" ]; then-    . "/tmp/SLACK_JOB_STATUS" # this is required for fetching the job status set by the notify.yml command.+    ShouldPost     CheckEnvVars+    . "/tmp/SLACK_JOB_STATUS"

This is the bug in 4.1.2. This has to come before ShouldPost since that uses CCI_STATUS to decide if the job should be run.

gmemstr

comment created time in 3 days

issue commentCircleCI-Public/slack-orb

CCI_STATUS empty in Slack Sending Notification job step

The ./tmp/SLACK_JOB_STATUS needs to come BEFORE ShouldPost.

bmilekic

comment created time in 3 days

issue commentCircleCI-Public/slack-orb

Slack Orb can not find the channel

So I figured out my issue. I had a command in my config to download a custom template, export that to an env var, and use that as my dynamic template. I then use my notify_failure command at the end of my jobs.

commands:
  notify_failure:
    description: Notifies slack of a job failure
    steps:
      - run:
          name: Load Slack template
          command: |
            curl https://cdn.mydomain.com/slack-templates/failed-build-template.json -o ~/tmp/templates/failed-build-template.json --create-dirs && \
            echo 'export FAILED_BUILD_TEMPLATE=$(cat ~/tmp/templates/failed-build-template.json)' >> $BASH_ENV
      - run: 
          name: Print Slack template
          command: |
            echo "Template: $FAILED_BUILD_TEMPLATE"
      - slack/notify:
          event: fail
          template: FAILED_BUILD_TEMPLATE
# ...

jobs:
  setup:
    description: Custom job
    steps:
      - checkout
      - run:
          name: Custom job command
          command: echo "This is my job"
      - notify_failure

If the "Custom job command" failed in my "Custom job", the "Load slack template" and "Print slack template" steps in notify_failure never get called since CircleCI defaults to when: on_success, and the slack/notify command prints the channel_not_found error.

Adding the following to my steps resolves the issue

commands:
  notify_failure:
    description: Notifies slack of a job failure
    steps:
      - run:
          when: on_fail # <-- Need to run this on failure to ensure template is loaded.
          name: Load Slack template
          command: |
            curl https://cdn.signalapis.com/slack-templates/failed-build-template.json -o ~/tmp/templates/failed-build-template.json --create-dirs && \
            echo 'export FAILED_BUILD_TEMPLATE=$(cat ~/tmp/templates/failed-build-template.json)' >> $BASH_ENV
      - run: 
          when: on_fail
          name: Print Slack template
          command: |
            echo "Template: $FAILED_BUILD_TEMPLATE"
      - slack/notify:
          event: fail
          template: FAILED_BUILD_TEMPLATE

That being said, can we add some better error messaging if the template: provided does not exist?

as-gennadiy-n

comment created time in 3 days

issue commentCircleCI-Public/slack-orb

CCI_STATUS empty in Slack Sending Notification job step

Hi, I have the same problem on 4.1.2, by switching back to 4.1.1 works again

bmilekic

comment created time in 3 days

issue commentCircleCI-Public/slack-orb

Slack Orb can not find the channel

@as-gennadiy-n Can you clarify if you were able to get it to work with a dynamic template or if you are using one of the built-in templates?

I am still running into this channel_not_found error when trying to send a message with a dynamic template to a public channel.

as-gennadiy-n

comment created time in 3 days

issue commentCircleCI-Public/slack-orb

Config keys that allows specifying CircleCI -> SlackID mappings + the ability to automatically mention the commiter

For teams that have numerous projects, this would have to be duplicated and maintained in each project, would it not?

How about using JSON extracted from an environment variable in addition to, or instead of a YAML file in the repo? That way, CCI contexts could be used to populate this globally.

0xdevalias

comment created time in 4 days

issue openedCircleCI-Public/slack-orb

Config keys that allows specifying CircleCI -> SlackID mappings + the ability to automatically mention the commiter

Describe Request:

Currently we appear to have access to Slack mentions via SLACK_PARAM_MENTIONS, but to my knowledge this requires the CircleCI username and the Slack username to be aligned. It would be great if we had some easy way of mapping the CircleCI usernames to Slack usernames, so that we can easily and automatically mention the committer causing a failure, etc; rather than the whole channel/team each time.

Examples:

eg. in https://github.com/abeyuya/actions-mention-to-slack#example-usage we can configure mappings like:

.github/mention-to-slack.yml

# For Github User
# github_username: "slack_member_id"

github_username_A: "slack_member_id_A"
github_username_B: "slack_member_id_B"
github_username_C: "slack_member_id_C"
abeyuya: "XXXXXXXXX"

# For Github Team
# github_teamname: "slack_member_id"

github_teamname_A: "slack_member_id_D"

Supporting Documentation Links:

  • https://circleci.com/developer/orbs/orb/circleci/slack

created time in 4 days

issue commentCircleCI-Public/slack-orb

CCI_STATUS empty in Slack Sending Notification job step

Hi @KyleTryon, I have a similar problem.

I am running circleci/slack@4.1.2 and the line . "/tmp/SLACK_JOB_STATUS" is present in the script, however CCI_STATUS is still empty as you can see on the screenshot:

image

bmilekic

comment created time in 4 days

issue commentCircleCI-Public/slack-orb

Impossible to filter on empty tag name.

@rogersd it matches either tag name or branch name. You can try something like that if I understand properly your use case:

branch_pattern: something_that_will_never_match
tag_pattern: your_tag_match

Let me know if that works for you and sorry for any inconvenience that it may have caused.

rogersd

comment created time in 4 days

issue commentCircleCI-Public/slack-orb

Impossible to filter on empty tag name.

@skyeagle @KyleTryon Can one of you please take a look at this? The repeated notifications on untagged deployments are annoying my integration team.

Thanks.

rogersd

comment created time in 4 days

issue closedCircleCI-Public/slack-orb

Notify command should stop as soon as possible when no notification should be sent

The line referenced below should be executed as soon as possible so we avoid taking unnecessary steps (such as installing dependencies) if no notification should be sent (e.g. the notification should be sent on fail but the job passed). This will make the CI faster when no Slack message needs to be sent.

https://github.com/CircleCI-Public/slack-orb/blob/5435b8129cdade77c990e6e07ae7de0f0a4c0261/src/scripts/notify.sh#L43

closed time in 4 days

ralbertazzi

created tagCircleCI-Public/slack-orb

tagv4.1.2

Create custom Slack notifications for CircleCI job statuses

created time in 5 days

delete branch CircleCI-Public/slack-orb

delete branch : decide-early

delete time in 5 days

push eventCircleCI-Public/slack-orb

Gabriel Simmer

commit sha 02a797c0ab5df3fef7ac0be5c91986f4cf4021b9

[semver:patch] Decide earlier whether to post message (#213)

view details

push time in 5 days

push eventCircleCI-Public/slack-orb

Gabriel Simmer

commit sha eec0db4cd955e9d8ea3178038c682cbcc3a3d621

Revert.

view details

push time in 5 days

push eventCircleCI-Public/slack-orb

Gabriel Simmer

commit sha f6db35d9b4248365aefec6c9cf6a8cfea61839a7

. > source for POSIX.

view details

push time in 5 days

more