Notification when build starts

Suganya's Avatar

Suganya

26 Feb, 2020 03:20 PM

Hi,

I want to send notification to RocketChat when build starts. I get notification when it completes (pass/fail). How can I send ' Build Started'?
I have checked all 3 checkboxes in notification settings - Build success, build failure and Build status changed. But it isn't sending for build starts.

  1. Support Staff 1 Posted by Feodor Fitsner on 26 Feb, 2020 06:35 PM

    Feodor Fitsner's Avatar

    There is no way to send built-in notification at the start of the build. However, you can easily call that endpoint with a simple curl or Invoke-WebRequest command in init section of your appveyor.yml.

  2. 2 Posted by Suganya Karunan... on 27 Feb, 2020 07:50 PM

    Suganya Karunanidhi's Avatar

    Hi Feodor,

    Thanks for the quick response. Do you have a sample I can use pls.?

    *From:* Feodor Fitsner <[email blocked]>
    *Sent:* Wednesday, February 26, 2020 1:35 PM
    *To:* [email blocked]
    *Subject:* Re: Notification when build starts [Questions #46819]

  3. 3 Posted by Suganya Karunan... on 27 Feb, 2020 07:51 PM

    Suganya Karunanidhi's Avatar

    I am trying below script and it doesn't work..

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    $Body = @{
        User = 'Suganya'
        password = 'Hello'
    }

    Invoke-WebRequest -Uri 'https://chat.imobile3.com/hooks/***********' -Headers @{'X-RocketChat-Channel' = '#cicd'} -Body $Body -Method Post -ErrorAction Stop

  4. Support Staff 4 Posted by Feodor Fitsner on 27 Feb, 2020 07:53 PM

    Feodor Fitsner's Avatar

    What error do you get?

  5. 5 Posted by Suganya Karunan... on 27 Feb, 2020 08:09 PM

    Suganya Karunanidhi's Avatar

    Invoke-WebRequest : {"success":false,"error":"error-running-script"}

    At line:8 char:1

    + Invoke-WebRequest -Uri 'https://chat.imobile3.com/hooks/TeAdLCzXAqw2a ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo : InvalidOperation:
    (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException

        + FullyQualifiedErrorId :
    WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

    *From:* Feodor Fitsner <[email blocked]>
    *Sent:* Thursday, February 27, 2020 2:54 PM
    *To:* [email blocked]
    *Subject:* Re: Notification when build starts [Questions #46819]

  6. Support Staff 6 Posted by Feodor Fitsner on 27 Feb, 2020 08:13 PM

    Feodor Fitsner's Avatar

    Is it a full error stack trace? It's hard to see what's wrong with the request. What do you get when running the same piece locally?

  7. 7 Posted by Suganya Karunan... on 27 Feb, 2020 08:22 PM

    Suganya Karunanidhi's Avatar

    I get the same error locally as well.. The error is "The remote server returned an error: (400) Bad Request."

    Invoke-WebRequest : {"success":false,"error":"error-running-script"}
    At line:24 char:1
    + Invoke-WebRequest -Uri 'https://chat.imobile3.com/hooks/TeAdLCzXAqw2a ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    Command executed with exception: The remote server returned an error: (400) Bad Request.

  8. Support Staff 8 Posted by Feodor Fitsner on 27 Feb, 2020 08:27 PM

    Feodor Fitsner's Avatar

    I'm not familiar with RocketChat, but looking at their API docs it seems you are calling it wrong: https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage...

  9. 9 Posted by Suganya Karunan... on 27 Feb, 2020 08:31 PM

    Suganya Karunanidhi's Avatar

    How is AppVeyor calling the webhook? Because below is all the configuration
    is set in it..

    - provider: Webhook

      url: https://chat.imobile3.com/hooks/***Y7

     method: POST

      headers:

        X-RocketChat-Channel: '#cicd'

      on_build_success: true

      on_build_failure: true

      on_build_status_changed: true

    *From:* Feodor Fitsner <[email blocked]>
    *Sent:* Thursday, February 27, 2020 3:27 PM
    *To:* [email blocked]
    *Subject:* Re: Notification when build starts [Questions #46819]

  10. Support Staff 10 Posted by Feodor Fitsner on 27 Feb, 2020 08:32 PM

    Feodor Fitsner's Avatar

    You mean you are already calling like that and it works?

  11. 11 Posted by Suganya Karunan... on 27 Feb, 2020 08:52 PM

    Suganya Karunanidhi's Avatar

    Yes, the AppVeyor webhook works. But it does not send a notification when
    the build starts and I want to notify that. You mentioned using a
    PowerShell webrequest but it is throwing an error.

    *From:* Feodor Fitsner <[email blocked]>
    *Sent:* Thursday, February 27, 2020 3:33 PM
    *To:* [email blocked]
    *Subject:* Re: Notification when build starts [Questions #46819]

  12. Support Staff 12 Posted by Feodor Fitsner on 27 Feb, 2020 08:55 PM

    Feodor Fitsner's Avatar

    Your PowerShell script differs from a screenshot in the initial post. In webhook settings you don't have a body while PS script sends username/password in the body.

  13. 13 Posted by Suganya Karunan... on 27 Feb, 2020 09:04 PM

    Suganya Karunanidhi's Avatar

    What is the request body that AppVeyor sends? I am just trying a sample
    body for the request.. Can you pls. share the request body that AppVeyor
    sets for build

    *From:* Feodor Fitsner <[email blocked]>
    *Sent:* Thursday, February 27, 2020 3:56 PM
    *To:* [email blocked]
    *Subject:* Re: Notification when build starts [Questions #46819]

  14. Support Staff 14 Posted by Feodor Fitsner on 27 Feb, 2020 09:07 PM

    Feodor Fitsner's Avatar
  15. Feodor Fitsner closed this discussion on 29 Apr, 2020 09:02 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

01 Oct, 2024 04:27 PM
26 Sep, 2024 03:49 PM
26 Sep, 2024 09:02 AM
25 Sep, 2024 07:07 PM
24 Sep, 2024 08:39 PM
24 Sep, 2024 06:47 AM