CircleCI-Public / slack-orb

Create custom Slack notifications for CircleCI job statuses
https://circleci.com/developer/orbs/orb/circleci/slack
MIT License
215 stars 205 forks source link

Version 4.12.1 `notify` doesn't work as expected on the Windows executor #387

Closed liberato-whisper closed 1 year ago

liberato-whisper commented 1 year ago

Orb version:

4.12.1

What happened:

The powershell execution of the slack/notify command doesn't work:

#!powershell.exe -ExecutionPolicy Bypass
#!/usr/bin/env sh

# Workaround for Windows Support
# For details, see: https://github.com/CircleCI-Public/slack-orb/pull/380
# shellcheck source=/dev/null
eval printf '%s' "$SLACK_SCRIPT_NOTIFY"

eval : The term 'eval' is not recognized as the name of a cmdlet, function, script file, or operable program. Check 
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:6 char:1
+ eval printf '%s' "$SLACK_SCRIPT_NOTIFY"
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (eval:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Exited with code exit status 1

Expected behavior:

Notification works as expected (and does on linux executors)

Additional Information:

Using

  executor:
    name: windows/default

step definition is

    - when:
        condition:
          equal: [ master, << pipeline.git.branch >> ]
        steps:
          - slack/notify:
              event: fail
              template: basic_fail_1
stascnb commented 1 year ago

I will make another issue in a sec, but also doesnt work when using hashicorp/terraform:1.1.4 image

return pretty something similar, ive tried using different image, like nodejs and it worked fine

Posting Status
BASH_ENV file: /tmp/.hash-hash-build
Does Not Exist. Skipping file execution
Checking For JQ + CURL
SLACK ORB ERROR: CURL is required. Please install.
EricRibeiro commented 1 year ago

Hi @liberato-whisper 👋

It sounds like you are using the Windows executor with Powershell as your shell of choice. As mentioned in the F.A.Q., you must specify bash as the shell to get Slack working with Windows.

Nchona commented 1 year ago

I have the same issues as the returns the same exit code on my circleCi pipeline with @4.12.1

EricRibeiro commented 1 year ago

@Nchona, have you tried setting your executor's shell as bash.exe as I mentioned here?

EricRibeiro commented 1 year ago

I am closing this issue as no one commented back. For future reference, please specify the shell as bash.exe when using this orb with the Windows executor.