Trigger another project's build

Thomas Fresneau's Avatar

Thomas Fresneau

24 Oct, 2018 08:46 PM

Hi,
I'm trying to trigger the build of a different project.

I've tried adding a Webhook notification (see attached screenshot).
I've also tried adding the following deployment script:
$token = 'my-token' $headers = @{ "Authorization" = "Bearer $token"} $body = @{accountName = "my-account-name"; projectSlug = "the-project-I-want-to-trigger"} $bodyAsJson = $body | ConvertTo-json Invoke-Restmethod -uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Method Post -Body $bodyAsjson -ContentType "application/json"

Neither of these solutions work. Note that for testing purpose, I've created an email notification that works fine.

Can you help me figuring out what I am missing?

Thanks,

Thom

  1. Support Staff 1 Posted by Owen McDonnell on 24 Oct, 2018 10:18 PM

    Owen McDonnell's Avatar

    What is the error you get?
    Can you tried putting the content-type in the header.

  2. 2 Posted by Thomas Fresneau on 25 Oct, 2018 01:29 PM

    Thomas Fresneau's Avatar

    I actually don’t see any output related to neither the new post-deployment script nor notifications so no errors are displayed. I think the post-deployment is actually not triggered, so for debugging purpose, I’ve created a post-test script with the same content and got the following result:

    Invoke-Restmethod : {"message":"Project not found or access denied."}
    At line:6 char:1
    + Invoke-Restmethod -uri 'https://ci.appveyor.com/api/builds' -Headers ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    Command executed with exception: The remote server returned an error: (404) Not Found.

    I wonder if I have the same error in the notification I created but the error is hidden …

  3. Support Staff 3 Posted by Owen McDonnell on 25 Oct, 2018 05:02 PM

    Owen McDonnell's Avatar

    When you try from the UI are you certain that the UI config is being used (you should check Ignore appveyor.yml box in General tab)?

    Also, from and to which account are you sending this webhook?

    I have no trouble triggering a build that belongs to the same account with the configuration shown in the screenshot.

  4. 4 Posted by Thomas Fresneau on 25 Oct, 2018 06:20 PM

    Thomas Fresneau's Avatar

    Hi,

    Yes, I’ve checked Ignore appveyor.yml.

    The two projects (the one that’s triggering the build and the one I want to trigger) are part of the same account (which I am specifying in the request body).

    I’ve updated my project settings to include the authorization key in the HTTP headers that was missing in my original configuration but that doesn’t trigger the build either.

    Thom

  5. Support Staff 5 Posted by Owen McDonnell on 25 Oct, 2018 07:02 PM

    Owen McDonnell's Avatar

    I see you belong to two different accounts.
    Please double check that the api token you are using is from the correct account.

  6. 6 Posted by Thomas Fresneau on 25 Oct, 2018 08:41 PM

    Thomas Fresneau's Avatar

    Good catch! I was actually using the token for all accounts. After switching to use the token for the specific account hosting the project I wanted to trigger, it worked.

    Thanks for your help.

    Thom

  7. Owen McDonnell closed this discussion on 25 Oct, 2018 09:18 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