tag:help.appveyor.com,2012-11-13:/discussions/questions/46819-notification-when-build-startsAppVeyor: Discussion 2020-04-29T21:02:47Ztag:help.appveyor.com,2012-11-13:Comment/481187252020-02-26T18:35:17Z2020-02-26T18:35:17ZNotification when build starts<div><p>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 <code>curl</code> or <code>Invoke-WebRequest</code> command in <code>init</code> section of your <code>appveyor.yml</code>.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T19:50:16Z2020-02-27T19:50:16ZNotification when build starts<div><p>Hi Feodor,</p>
<p>Thanks for the quick response. Do you have a sample I can use pls.?</p>
<p><em>From:</em> Feodor Fitsner <a href="mailto:tender2+d920554604@tenderapp.com">tender2+d920554604@tenderapp.com</a> <em>Sent:</em> Wednesday, February 26, 2020 1:35 PM <em>To:</em> <a href="mailto:skarunanidhi@imobile3.com">skarunanidhi@imobile3.com</a> <em>Subject:</em> Re: Notification when build starts [Questions #46819]</p></div>Suganya Karunanidhitag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T19:51:57Z2020-02-27T19:51:58ZNotification when build starts<div><p>I am trying below script and it doesn't work..</p>
<p>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12</p>
<p>$Body = @{ User = 'Suganya' password = 'Hello' }</p>
<p>Invoke-WebRequest -Uri '<a href="https://chat.imobile3.com/hooks/***********">https://chat.imobile3.com/hooks/***********</a>' -Headers @{'X-RocketChat-Channel' = '#cicd'} -Body $Body -Method Post -ErrorAction Stop</p></div>Suganya Karunanidhitag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T19:53:38Z2020-02-27T19:53:38ZNotification when build starts<div><p>What error do you get?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:09:19Z2020-02-27T20:09:20ZNotification when build starts<div><p>Invoke-WebRequest : {<a href=""error-running-script"}">success":false,"error</a></p>
<p>At line:8 char:1</p>
<ul>
<li>
<p>Invoke-WebRequest -Uri '<a href="https://chat.imobile3.com/hooks/TeAdLCzXAqw2a">https://chat.imobile3.com/hooks/TeAdLCzXAqw2a</a> ...</p>
</li>
<li>
<ul>
<li>CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException</li>
<li>FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand</li>
</ul>
</li>
</ul>
<p><em>From:</em> Feodor Fitsner <a href="mailto:tender2+d920554604@tenderapp.com">tender2+d920554604@tenderapp.com</a> <em>Sent:</em> Thursday, February 27, 2020 2:54 PM <em>To:</em> <a href="mailto:skarunanidhi@imobile3.com">skarunanidhi@imobile3.com</a> <em>Subject:</em> Re: Notification when build starts [Questions #46819]</p></div>Suganya Karunanidhitag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:13:17Z2020-02-27T20:13:17ZNotification when build starts<div><p>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?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:22:39Z2020-02-27T20:22:39ZNotification when build starts<div><p>I get the same error locally as well.. The error is <a href=""error-running-script"}">The remote server returned an error: (400) Bad Request."</a></p>
<p><a href=""error-running-script"}">Invoke-WebRequest : {"success":false,"error</a><br>
At line:24 char:1<br>
+ Invoke-WebRequest -Uri '<a href="https://chat.imobile3.com/hooks/TeAdLCzXAqw2a">https://chat.imobile3.com/hooks/TeAdLCzXAqw2a</a> ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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.</p></div>Suganya Karunanidhitag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:27:13Z2020-02-27T20:27:13ZNotification when build starts<div><p>I'm not familiar with RocketChat, but looking at their API docs it seems you are calling it wrong: <a href="https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/#example-call">https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage...</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:31:32Z2020-02-27T20:31:32ZNotification when build starts<div><p>How is AppVeyor calling the webhook? Because below is all the configuration<br>
is set in it..</p>
<ul>
<li>provider: Webhook</li>
</ul>
<p>url: <a href="https://chat.imobile3.com/hooks/***Y7">https://chat.imobile3.com/hooks/***Y7</a></p>
<p>method: POST</p>
<p>headers:</p>
<pre>
<code>X-RocketChat-Channel: '#cicd'</code>
</pre>
<p>on_build_success: true</p>
<p>on_build_failure: true</p>
<p>on_build_status_changed: true</p>
<p><em>From:</em> Feodor Fitsner <a href="mailto:tender2+d920554604@tenderapp.com">tender2+d920554604@tenderapp.com</a> <em>Sent:</em> Thursday, February 27, 2020 3:27 PM <em>To:</em> <a href="mailto:skarunanidhi@imobile3.com">skarunanidhi@imobile3.com</a> <em>Subject:</em> Re: Notification when build starts [Questions #46819]</p></div>Suganya Karunanidhitag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:32:52Z2020-02-27T20:32:52ZNotification when build starts<div><p>You mean you are already calling like that and it works?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:52:40Z2020-02-27T20:52:41ZNotification when build starts<div><p>Yes, the AppVeyor webhook works. But it does not send a notification when<br>
the build starts and I want to notify that. You mentioned using a<br>
PowerShell webrequest but it is throwing an error.</p>
<p><em>From:</em> Feodor Fitsner <a href="mailto:tender2+d920554604@tenderapp.com">tender2+d920554604@tenderapp.com</a> <em>Sent:</em> Thursday, February 27, 2020 3:33 PM <em>To:</em> <a href="mailto:skarunanidhi@imobile3.com">skarunanidhi@imobile3.com</a> <em>Subject:</em> Re: Notification when build starts [Questions #46819]</p></div>Suganya Karunanidhitag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T20:55:51Z2020-02-27T20:55:51ZNotification when build starts<div><p>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.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T21:04:26Z2020-02-27T21:04:27ZNotification when build starts<div><p>What is the request body that AppVeyor sends? I am just trying a sample<br>
body for the request.. Can you pls. share the request body that AppVeyor<br>
sets for build</p>
<p><em>From:</em> Feodor Fitsner <a href="mailto:tender2+d920554604@tenderapp.com">tender2+d920554604@tenderapp.com</a> <em>Sent:</em> Thursday, February 27, 2020 3:56 PM <em>To:</em> <a href="mailto:skarunanidhi@imobile3.com">skarunanidhi@imobile3.com</a> <em>Subject:</em> Re: Notification when build starts [Questions #46819]</p></div>Suganya Karunanidhitag:help.appveyor.com,2012-11-13:Comment/481187252020-02-27T21:07:57Z2020-02-27T21:07:57ZNotification when build starts<div><p>This is it: <a href="https://www.appveyor.com/docs/notifications/#webhook-payload-default">https://www.appveyor.com/docs/notifications/#webhook-payload-default</a></p></div>Feodor Fitsner