Search in sources :

Example 1 with PromotionStatusBuilder

use of org.jfrog.build.api.builder.PromotionStatusBuilder in project build-info by JFrogDev.

the class BuildTest method testStatusAddMethod.

public void testStatusAddMethod() {
    Build build = new Build();
    assertNull(build.getStatuses(), "Default status list should be null.");
    PromotionStatus promotionStatus = new PromotionStatusBuilder(Promotion.RELEASED).repository("bla").timestamp("bla").user("bla").build();
    build.addStatus(promotionStatus);
    assertFalse(build.getStatuses().isEmpty(), "Status object should have been added.");
    assertEquals(build.getStatuses().get(0), promotionStatus, "Unexpected status object.");
    PromotionStatus anotherPromotionStatus = new PromotionStatusBuilder(Promotion.RELEASED).repository("bla").timestamp("bla").user("bla").build();
    build.addStatus(anotherPromotionStatus);
    assertEquals(build.getStatuses().size(), 2, "Second status object should have been added.");
    assertEquals(build.getStatuses().get(1), anotherPromotionStatus, "Unexpected status object.");
}
Also used : PromotionStatusBuilder(org.jfrog.build.api.builder.PromotionStatusBuilder) PromotionStatus(org.jfrog.build.api.release.PromotionStatus)

Example 2 with PromotionStatusBuilder

use of org.jfrog.build.api.builder.PromotionStatusBuilder in project build-info by JFrogDev.

the class BuildInfoModelPropertyResolver method attachStagingIfNeeded.

private void attachStagingIfNeeded(ArtifactoryClientConfiguration clientConf, BuildInfoMavenBuilder builder) {
    if (clientConf.info.isReleaseEnabled()) {
        String stagingRepository = clientConf.publisher.getRepoKey();
        String comment = clientConf.info.getReleaseComment();
        if (comment == null) {
            comment = "";
        }
        String buildStartedIso = clientConf.info.getBuildStarted();
        Date buildStartDate;
        try {
            buildStartDate = new SimpleDateFormat(Build.STARTED_FORMAT).parse(buildStartedIso);
        } catch (ParseException e) {
            throw new IllegalArgumentException("Build start date format error: " + buildStartedIso, e);
        }
        builder.addStatus(new PromotionStatusBuilder(Promotion.STAGED).timestampDate(buildStartDate).comment(comment).repository(stagingRepository).ciUser(clientConf.info.getPrincipal()).user(clientConf.publisher.getUsername()).build());
    }
}
Also used : PromotionStatusBuilder(org.jfrog.build.api.builder.PromotionStatusBuilder) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

PromotionStatusBuilder (org.jfrog.build.api.builder.PromotionStatusBuilder)2 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 PromotionStatus (org.jfrog.build.api.release.PromotionStatus)1