Commit SHA of last successful build

peter.dunshee's Avatar

peter.dunshee

17 Feb, 2015 09:52 PM

Is there a way to get the commit SHA of the *last* successful build? I'd like to get the commit log from that point until the current SHA in order to send the changelog in the new builds that will be deployed using AppVeyor.

Thanks,
Peter

  1. Support Staff 1 Posted by Feodor Fitsner on 17 Feb, 2015 11:20 PM

    Feodor Fitsner's Avatar

    Hi Peter,

    You can use this API method to check project history: http://www.appveyor.com/docs/api/projects-builds#get-project-history

    -Feodor

  2. 2 Posted by peter.dunshee on 18 Feb, 2015 06:25 PM

    peter.dunshee's Avatar

    Hi Feodor,

    I’ve used your info to produce a script that fetches the info I need. I’ve
    noticed a few strange things in the process:

    1. I couldn’t use the AppVeyor environment variables to get the
    project name/slug; I had to hardcode those into the powershell script

    2. The secure variable for the token didn’t seem to work either; so I
    stuck the token into the powershell script

    3. The last SHA didn’t seem to give me a valid commit log (empty)

    Per #3, is the top build SHA returned from the “history” API the same as
    the currently running build? Ie. Should I search back in the list for the
    successful build prior to the last one returned? (Btw, it would be super
    handy if this were just an environment variable, like the other one; I feel
    silly calling the REST API from inside the build agent)

    Thanks,
    Peter

    *From:* Feodor Fitsner [mailto:[email blocked]]
    *Sent:* Tuesday, February 17, 2015 5:20 PM
    *To:* [email blocked]
    *Subject:* Re: Commit SHA of last successful build [Questions #994]

  3. Support Staff 3 Posted by Feodor Fitsner on 18 Feb, 2015 06:30 PM

    Feodor Fitsner's Avatar

    Yes, you should go down the history to find the latest successful build.

    Regarding #1 and #2 - can I look at your script please?

    Calling API from build agent is not a problem, IMO. As you understand we can't cover all scenarios and specific cases and have variables for those.

  4. 4 Posted by jondick on 21 Jan, 2016 02:13 PM

    jondick's Avatar

    I'd like to ask that you consider adding the Commit SHA of the last successful build to the environment variables.

    The Jenkins Git plugin provides this information in the environment variable: GIT_PREVIOUS_SUCCESSFUL_COMMIT and it's really useful to be able to in my build script find a list of files changed since the last successful build to know what needs to be processed. I too have built something using the REST API but it's a bit clunky needing to pass in the API Token, account name, and project slug...

    Please consider adding this?

  5. Support Staff 5 Posted by Feodor Fitsner on 22 Jan, 2016 02:11 AM

    Feodor Fitsner's Avatar
  6. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:03 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