code: @Nonnull
      public static ObjectId getCommitSHA1(@Nonnull Run<?, ?> build) throws IOException {
          List<BuildData> buildDataList = build.getActions(BuildData.class);
  
          Job<?, ?> parent = build.getParent();
  
          BuildData buildData = calculateBuildData(
              parent.getName(), parent.getFullName(), buildDataList
          );
  
          if (buildData == null) {
              throw new IOException(Messages.BuildDataHelper_NoBuildDataError());
          }
  
          // buildData?.lastBuild?.marked and fall back to .revision with null check everywhere to be defensive
          Build b = buildData.lastBuild;
          if (b != null) {
              Revision r = b.marked;
              if (r == null) {
                  r = b.revision;
              }
              if (r != null) {
                  return r.getSha1();
              }
          }
  
          // Nowhere to report => fail the build
          throw new IOException(Messages.BuildDataHelper_NoLastRevisionError());
      }
docs: Gets SHA1 from the build.
  
  @param build
  
  @return SHA1 of the las
  @throws IOException Cannot get the info about commit ID