How to get information of triggering project from inside of acceptance test

I have 2 project, and on of them is acceptance test, and the other one is MainProject. After the main project build then starts acceptance test and then I'm having email send to me when acceptance test finished. I'm using standart email template.
I'm wondering can I get {projectName}, {commitAuthor}, {commitAuthorEmail}, {commitMessage} of MainProject. Is it possible ? I tried find something like that but I couldn't find anything.

My email template:

<div style="font-family:'Segoe UI',Arial,Sans-Serif;font-size:10pt;">
    {{#passed}}
    <h1 style="font-size: 150%;font-weight:normal; color:#078DC7;"><a href="{{buildUrl}}" style="color:#078DC7;">Build {{projectName}} {{buildVersion}} completed</a></h1>{{/passed}}
    {{#failed}}
    <h1 style="font-size: 150%;font-weight:normal; color:#ff3228;"><a href="{{buildUrl}}" style="color:#ff3228;">Build {{projectName}} {{buildVersion}} failed</a></h1>{{/failed}}
    <p style="color: #888;">
        Commit <a href="{{commitUrl}}">{{commitId}}</a> by <a href="mailto:{{commitAuthorEmail}}">{{commitAuthor}}</a> on {{commitDate}}:
        <br />
        <span style="font-size: 110%;color:#222;">{{commitMessage}}</span>
    </p>
    <p><a href="{{notificationSettingsUrl}}" style="font-size:85%;color:#999;">Configure your notification preferences</a></p>
</div>

  1. So, you start second project build using AppVeyor REST API?

    - Feodor

  2. Hi Feodor, thanks for reply

    I'm running this script after main project deployment to run the acceptance-tests project

    $token = 'xxxxxx'
    $headers = @{ "Authorization" = "Bearer $token"}
    $body = @{accountName = "myaccount"; projectSlug = "myproject-acceptance-tests"}
    $bodyAsJson = $body | ConvertTo-json
    Invoke-Restmethod -uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Method Post -Body $bodyAsjson -ContentType "application/json"

  3. Great. You can grab the information about current (parent) build from environment variables and pass it to the second build in environment variables: http://www.appveyor.com/docs/api/projects-builds#start-build-of-bra...

    Let me know if you have any questions.

  4. Thank you Feodor, i will try this

  5. I tired but it didn't work, maybe i used wrong.

    I changed my script like this:

    $token = 'xxxxxx'
    $headers = @{ "Authorization" = "Bearer $token"}
    $body = @{accountName = "myaccount"; projectSlug = "myproject-acceptance-tests";
    environmentVariables: {
           tolgaTest: 'tolga test value',
           webSitesCommit: '$APPVEYOR_REPO_COMMIT'
        }
    }
    $bodyAsJson = $body | ConvertTo-json
    Invoke-Restmethod -uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Method Post -Body $bodyAsjson -ContentType "application/json"

    And my acceptance test notification mail template is below:

    Build {{status}}: {{projectName}} {{buildVersion}}

    Broker Websites Commit: {{webSitesCommit}}

    Tolga Test: {{tolgaTest}}

    I recived fail message:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     environmentVariables: {
    + ~
    Missing '=' operator after key in hash literal.
     
    At line:10 char:7
    + Invoke-Restmethod -uri 'https://ci.appveyor.com/api/builds' -Headers $headers -M ...
    + ~
    Missing '=' operator after key in hash literal.
     
    At line:10 char:7
    + Invoke-Restmethod -uri 'https://ci.appveyor.com/api/builds' -Headers $headers -M ...
    + ~
    The hash literal was incomplete.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    Then i changed environmentVariables like this:

    environmentVariables = {
           tolgaTest: 'tolga test value',
           webSitesCommit: '$APPVEYOR_REPO_COMMIT'
        }

    And I recived error is:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Invoke-Restmethod : {"message":"The request is invalid.","modelState":{"request.environmentVariables.Attributes":["An error has occurred."],"request.environmentVariables.StartPosition":["An error has
    occurred."],"request.environmentVariables.Ast":["An error has occurred."]}}
    At line:10 char:1
    + Invoke-Restmethod -uri 'https://ci.appveyor.com/api/builds' -Headers $headers -M ...
    +
     + 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: (400) Bad Request.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  6. The problem with hash definition. Should be:

    $body = @{
        accountName = "myaccount"
        projectSlug = "myproject-acceptance-tests"
        environmentVariables = @{ 
           tolgaTest = 'tolga test value'
           webSitesCommit = '$APPVEYOR_REPO_COMMIT' 
        }
    }
    
    $bodyAsJson = $body | ConvertTo-json
    
  7. I tried but it didn't work.

    My email script like this

    {{projectName}}
    tolga test: {{tolgaTest }}
    webSitesCommit : {{webSitesCommit}}

    I recived mail like this:
    -------------------------------------
    AcceptanceTest
    tolga test:
    webSitesCommit:
    -------------------------------------

  8. Oh, forgot to mention - environment variables are not supported in mail templates. Feel free to submit a feature request here: https://github.com/appveyor/ci/issues

  9. Ok Feodor, thanks for your interest and i opened an issue about this

    https://github.com/appveyor/ci/issues/294

  10. This event necessary for me. Is there any progress?

  11. Could you elaborate on your scenario please?

    - Feodor

  12. I have a project A triggers acceptance test after building. When acceptance test fails it sends me an email says that the last build version of acceptance test failed, which makes me confused is the acceptance test faild because it is not building or because it is couldn't pass the test ?
    It should say that the last version of project A failed so I know that acceptance test didn't pass.

  13. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:05 AM.

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