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

Tolga's Avatar

Tolga

05 Jun, 2015 03:04 PM

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. Support Staff 1 Posted by Feodor Fitsner on 05 Jun, 2015 10:38 PM

    Feodor Fitsner's Avatar

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

    - Feodor

  2. 2 Posted by Tolga on 09 Jun, 2015 06:56 AM

    Tolga's Avatar

    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. Support Staff 3 Posted by Feodor Fitsner on 09 Jun, 2015 05:19 PM

    Feodor Fitsner's Avatar

    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. 4 Posted by Tolga on 10 Jun, 2015 06:57 AM

    Tolga's Avatar

    Thank you Feodor, i will try this

  5. 5 Posted by Tolga on 11 Jun, 2015 07:47 AM

    Tolga's Avatar

    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. Support Staff 6 Posted by Feodor Fitsner on 11 Jun, 2015 06:34 PM

    Feodor Fitsner's Avatar

    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. 7 Posted by Tolga on 12 Jun, 2015 11:31 AM

    Tolga's Avatar

    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. Support Staff 8 Posted by Feodor Fitsner on 12 Jun, 2015 04:54 PM

    Feodor Fitsner's Avatar

    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. 9 Posted by Tolga on 15 Jun, 2015 06:51 AM

    Tolga's Avatar

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

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

  10. 10 Posted by turgut.kancelti... on 11 Nov, 2015 09:10 AM

    turgut.kanceltik's Avatar

    This event necessary for me. Is there any progress?

  11. Support Staff 11 Posted by Feodor Fitsner on 11 Nov, 2015 08:09 PM

    Feodor Fitsner's Avatar

    Could you elaborate on your scenario please?

    - Feodor

  12. 12 Posted by turgut.kancelti... on 25 Mar, 2016 07:54 AM

    turgut.kanceltik's Avatar

    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