* @param build
* @return SHA1 of the las
* @throws IOException Cannot get the info about commit ID
*/
public static @Nonnull ObjectId getCommitSHA1(@Nonnull AbstractBuild<?, ?> build) throws IOException {
BuildData buildData = build.getAction(BuildData.class);
if (buildData == null) {
throw new IOException(Messages.BuildDataHelper_NoBuildDataError());
}
final Revision lastBuildRevision = buildData.getLastBuiltRevision();
final ObjectId sha1 = lastBuildRevision != null ? lastBuildRevision.getSha1() : null;
if (sha1 == null) { // Nowhere to report => fail the build
throw new IOException(Messages.BuildDataHelper_NoLastRevisionError());
}
return sha1;