From a793f0c5703cb0d34026ba9f5ff7e2763cc4856a Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Tue, 9 Jun 2026 15:14:22 +0100 Subject: [PATCH 1/2] Add upload and promote build --- .../org/jfrog/artifactory/client/Builds.java | 43 +++ .../artifactory/client/model/BuildInfo.java | 248 ++++++++++++++++++ .../client/model/BuildPromotionRequest.java | 100 +++++++ .../client/model/BuildPromotionResponse.java | 21 ++ .../client/model/PromotionMessage.java | 25 ++ .../artifactory/client/impl/BuildsImpl.java | 44 ++++ .../client/model/impl/BuildInfoImpl.java | 218 +++++++++++++++ .../model/impl/BuildPromotionRequestImpl.java | 152 +++++++++++ .../impl/BuildPromotionResponseImpl.java | 26 ++ .../model/impl/PromotionMessageImpl.java | 33 +++ .../jfrog/artifactory/client/BuildsTests.java | 79 +++++- .../org/jfrog/artifactory/client/Utils.java | 15 ++ 12 files changed, 1002 insertions(+), 2 deletions(-) create mode 100644 api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java create mode 100644 api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionRequest.java create mode 100644 api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionResponse.java create mode 100644 api/src/main/java/org/jfrog/artifactory/client/model/PromotionMessage.java create mode 100644 services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java create mode 100644 services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionRequestImpl.java create mode 100644 services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionResponseImpl.java create mode 100644 services/src/main/java/org/jfrog/artifactory/client/model/impl/PromotionMessageImpl.java diff --git a/api/src/main/java/org/jfrog/artifactory/client/Builds.java b/api/src/main/java/org/jfrog/artifactory/client/Builds.java index e4b32751..4d0651fa 100644 --- a/api/src/main/java/org/jfrog/artifactory/client/Builds.java +++ b/api/src/main/java/org/jfrog/artifactory/client/Builds.java @@ -1,6 +1,9 @@ package org.jfrog.artifactory.client; import org.jfrog.artifactory.client.model.AllBuilds; +import org.jfrog.artifactory.client.model.BuildInfo; +import org.jfrog.artifactory.client.model.BuildPromotionRequest; +import org.jfrog.artifactory.client.model.BuildPromotionResponse; import org.jfrog.artifactory.client.model.BuildRuns; import java.io.IOException; @@ -12,4 +15,44 @@ public interface Builds { AllBuilds getAllBuilds() throws IOException; BuildRuns getBuildRuns(String buildName) throws IOException; + + /** + * Upload a build to Artifactory + * + * @param buildInfo the build info + * @throws IOException if the upload fails + */ + void uploadBuild(BuildInfo buildInfo) throws IOException; + + /** + * Upload a build to Artifactory with a project parameter + * + * @param buildInfo the build info + * @param project the project name to limit the build to + * @throws IOException if the upload fails + */ + void uploadBuild(BuildInfo buildInfo, String project) throws IOException; + + /** + * Promote a build in Artifactory + * + * @param buildName the name of the build to promote + * @param buildNumber the number of the build to promote + * @param promotionRequest the promotion request details + * @return the promotion response with messages + * @throws IOException if the promotion fails + */ + BuildPromotionResponse promoteBuild(String buildName, String buildNumber, BuildPromotionRequest promotionRequest) throws IOException; + + /** + * Promote a build in Artifactory with a project parameter + * + * @param buildName the name of the build to promote + * @param buildNumber the number of the build to promote + * @param promotionRequest the promotion request details + * @param project the project name + * @return the promotion response with messages + * @throws IOException if the promotion fails + */ + BuildPromotionResponse promoteBuild(String buildName, String buildNumber, BuildPromotionRequest promotionRequest, String project) throws IOException; } diff --git a/api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java b/api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java new file mode 100644 index 00000000..63ab15d4 --- /dev/null +++ b/api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java @@ -0,0 +1,248 @@ +package org.jfrog.artifactory.client.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; +import java.util.Map; + +/** + * Build Info structure for uploading to Artifactory + * + * @author rnc + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public interface BuildInfo { + /** + * Build Info schema version + * @return the version + */ + String getVersion(); + + /** + * Build name + * @return the build name + */ + String getName(); + + /** + * Build number + * @return the build number + */ + String getNumber(); + + /** + * Build type (MAVEN, GRADLE, ANT, IVY, GENERIC) + * @return the build type + */ + String getType(); + + /** + * Build agent information (build tool) + * @return the build agent + */ + BuildAgent getBuildAgent(); + + /** + * CI agent information (CI server) + * @return the agent + */ + Agent getAgent(); + + /** + * Build start time in ISO 8601 format (yyyy-MM-dd'T'HH:mm:ss.SSSZ) + * @return the start time + */ + String getStarted(); + + /** + * Artifactory plugin version + * @return the plugin version + */ + String getArtifactoryPluginVersion(); + + /** + * Build duration in milliseconds + * @return the duration + */ + Long getDurationMillis(); + + /** + * Artifactory principal (the Artifactory user used for deployment) + * @return the principal + */ + String getArtifactoryPrincipal(); + + /** + * CI server URL + * @return the URL + */ + String getUrl(); + + /** + * VCS revision + * @return the VCS revision + */ + String getVcsRevision(); + + /** + * VCS URL + * @return the VCS URL + */ + String getVcsUrl(); + + /** + * VCS information list + * @return the VCS list + */ + List getVcs(); + + /** + * License control settings + * @return the license control + */ + LicenseControl getLicenseControl(); + + /** + * Build retention settings + * @return the build retention + */ + BuildRetention getBuildRetention(); + + /** + * Build modules + * @return the modules + */ + List getModules(); + + /** + * Issues information + * @return the issues + */ + Issues getIssues(); + + /** + * Governance information + * @return the governance + */ + Map getGovernance(); + + /** + * Environment variables and properties + * @return the properties + */ + Map getProperties(); + + /** + * Build agent (build tool) information + */ + interface BuildAgent { + String getName(); + String getVersion(); + } + + /** + * CI agent (CI server) information + */ + interface Agent { + String getName(); + String getVersion(); + } + + /** + * VCS information + */ + interface VcsInfo { + String getRevision(); + String getMessage(); + String getBranch(); + String getUrl(); + } + + /** + * License control settings + */ + interface LicenseControl { + Boolean getRunChecks(); + Boolean getIncludePublishedArtifacts(); + Boolean getAutoDiscover(); + String getScopesList(); + String getLicenseViolationsRecipientsList(); + } + + /** + * Build retention settings + */ + interface BuildRetention { + Boolean getDeleteBuildArtifacts(); + Integer getCount(); + Long getMinimumBuildDate(); + List getBuildNumbersNotToBeDiscarded(); + } + + /** + * Build module + */ + interface BuildModule { + Map getProperties(); + String getId(); + String getType(); + List getArtifacts(); + List getDependencies(); + } + + /** + * Build artifact + */ + interface Artifact { + String getType(); + String getSha1(); + String getSha256(); + String getMd5(); + String getName(); + String getPath(); + String getOriginalDeploymentRepo(); + } + + /** + * Build dependency + */ + interface Dependency { + String getType(); + String getSha1(); + String getSha256(); + String getMd5(); + String getId(); + List getScopes(); + List> getRequestedBy(); + } + + /** + * Issues information + */ + interface Issues { + Tracker getTracker(); + Boolean getAggregateBuildIssues(); + String getAggregationBuildStatus(); + List getAffectedIssues(); + } + + /** + * Issue tracker information + */ + interface Tracker { + String getName(); + String getVersion(); + } + + /** + * Affected issue + */ + interface AffectedIssue { + String getKey(); + String getUrl(); + String getSummary(); + Boolean getAggregated(); + } +} + +// Made with Bob diff --git a/api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionRequest.java b/api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionRequest.java new file mode 100644 index 00000000..3bb09323 --- /dev/null +++ b/api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionRequest.java @@ -0,0 +1,100 @@ +package org.jfrog.artifactory.client.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; +import java.util.Map; + +/** + * Request for promoting a build in Artifactory + * + * @author rnc + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public interface BuildPromotionRequest { + /** + * The new status of the build + * @return the status + */ + String getStatus(); + + /** + * An optional comment describing the reason for the promotion + * @return the comment + */ + String getComment(); + + /** + * The user that invoked promotion from the CI server + * @return the CI user + */ + @JsonProperty("ciUser") + String getCiUser(); + + /** + * The time when the promotion command was received by Artifactory (ISO8601 format) + * @return the timestamp + */ + String getTimestamp(); + + /** + * When set to true, performs a dry run of the promotion without executing any operation + * @return true for dry run + */ + @JsonProperty("dryRun") + Boolean getDryRun(); + + /** + * The repository from which the build contents will be copied or moved + * @return the source repository + */ + @JsonProperty("sourceRepo") + String getSourceRepo(); + + /** + * The target repository to which the build contents will be copied or moved + * @return the target repository + */ + @JsonProperty("targetRepo") + String getTargetRepo(); + + /** + * Determines how to perform the build promotion. true = copy, false = move + * @return true to copy, false to move + */ + Boolean getCopy(); + + /** + * Determines whether to move/copy the build's artifacts + * @return true to include artifacts + */ + Boolean getArtifacts(); + + /** + * Determines whether to move/copy the build's dependencies + * @return true to include dependencies + */ + Boolean getDependencies(); + + /** + * An array of dependency scopes + * @return the scopes + */ + List getScopes(); + + /** + * A list of properties to attach to the build's artifacts + * @return the properties + */ + Map getProperties(); + + /** + * When set to true, fails and aborts the promotion operation upon receiving an error + * @return true to fail fast + */ + @JsonProperty("failFast") + Boolean getFailFast(); +} + +// Made with Bob diff --git a/api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionResponse.java b/api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionResponse.java new file mode 100644 index 00000000..80891f61 --- /dev/null +++ b/api/src/main/java/org/jfrog/artifactory/client/model/BuildPromotionResponse.java @@ -0,0 +1,21 @@ +package org.jfrog.artifactory.client.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * Response from promoting a build in Artifactory + * + * @author rnc + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public interface BuildPromotionResponse { + /** + * Get the list of messages from the promotion operation + * @return the messages + */ + List getMessages(); +} + +// Made with Bob diff --git a/api/src/main/java/org/jfrog/artifactory/client/model/PromotionMessage.java b/api/src/main/java/org/jfrog/artifactory/client/model/PromotionMessage.java new file mode 100644 index 00000000..c3dc5ff2 --- /dev/null +++ b/api/src/main/java/org/jfrog/artifactory/client/model/PromotionMessage.java @@ -0,0 +1,25 @@ +package org.jfrog.artifactory.client.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * A message returned from a build promotion operation + * + * @author rnc + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public interface PromotionMessage { + /** + * The level of the message (error, warning, info) + * @return the message level + */ + String getLevel(); + + /** + * The message text + * @return the message + */ + String getMessage(); +} + +// Made with Bob diff --git a/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java b/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java index a6500d92..49044029 100644 --- a/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java +++ b/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java @@ -1,13 +1,21 @@ package org.jfrog.artifactory.client.impl; +import org.apache.http.entity.ContentType; import org.jfrog.artifactory.client.Artifactory; import org.jfrog.artifactory.client.Builds; +import org.jfrog.artifactory.client.impl.util.Util; import org.jfrog.artifactory.client.model.AllBuilds; +import org.jfrog.artifactory.client.model.BuildInfo; +import org.jfrog.artifactory.client.model.BuildPromotionRequest; +import org.jfrog.artifactory.client.model.BuildPromotionResponse; import org.jfrog.artifactory.client.model.BuildRuns; import org.jfrog.artifactory.client.model.impl.AllBuildsImpl; +import org.jfrog.artifactory.client.model.impl.BuildPromotionResponseImpl; import org.jfrog.artifactory.client.model.impl.BuildRunsImpl; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; /** * @author yahavi @@ -31,6 +39,42 @@ public BuildRuns getBuildRuns(String buildName) throws IOException { return artifactory.get(getBuilderApi() + buildName, BuildRunsImpl.class, BuildRuns.class); } + @Override + public void uploadBuild(BuildInfo buildInfo) throws IOException { + uploadBuild(buildInfo, null); + } + + @Override + public void uploadBuild(BuildInfo buildInfo, String project) throws IOException { + String apiPath = getBuilderApi(); + if (project != null && !project.isEmpty()) { + apiPath += "?project=" + project; + } + + Map headers = new HashMap<>(); + artifactory.put(apiPath, ContentType.APPLICATION_JSON, + Util.getStringFromObject(buildInfo), headers, null, -1, + String.class, null); + } + + @Override + public BuildPromotionResponse promoteBuild(String buildName, String buildNumber, BuildPromotionRequest promotionRequest) throws IOException { + return promoteBuild(buildName, buildNumber, promotionRequest, null); + } + + @Override + public BuildPromotionResponse promoteBuild(String buildName, String buildNumber, BuildPromotionRequest promotionRequest, String project) throws IOException { + String apiPath = getBuilderApi() + "promote/" + buildName + "/" + buildNumber; + if (project != null && !project.isEmpty()) { + apiPath += "?project=" + project; + } + + Map headers = new HashMap<>(); + return artifactory.post(apiPath, ContentType.APPLICATION_JSON, + Util.getStringFromObject(promotionRequest), headers, + BuildPromotionResponseImpl.class, BuildPromotionResponse.class); + } + public String getBuilderApi() { return baseApiPath + "/build/"; } diff --git a/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java b/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java new file mode 100644 index 00000000..087491c3 --- /dev/null +++ b/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java @@ -0,0 +1,218 @@ +package org.jfrog.artifactory.client.model.impl; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.jfrog.artifactory.client.model.BuildInfo; + +import java.util.List; +import java.util.Map; + +/** + * Implementation of BuildInfo + * + * @author rnc + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BuildInfoImpl implements BuildInfo { + private String version; + private String name; + private String number; + private String type; + private BuildAgent buildAgent; + private Agent agent; + private String started; + private String artifactoryPluginVersion; + private Long durationMillis; + private String artifactoryPrincipal; + private String url; + private String vcsRevision; + private String vcsUrl; + private List vcs; + private LicenseControl licenseControl; + private BuildRetention buildRetention; + private List modules; + private Issues issues; + private Map governance; + private Map properties; + + @Override + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + @Override + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public BuildAgent getBuildAgent() { + return buildAgent; + } + + public void setBuildAgent(BuildAgent buildAgent) { + this.buildAgent = buildAgent; + } + + @Override + public Agent getAgent() { + return agent; + } + + public void setAgent(Agent agent) { + this.agent = agent; + } + + @Override + public String getStarted() { + return started; + } + + public void setStarted(String started) { + this.started = started; + } + + @Override + public String getArtifactoryPluginVersion() { + return artifactoryPluginVersion; + } + + public void setArtifactoryPluginVersion(String artifactoryPluginVersion) { + this.artifactoryPluginVersion = artifactoryPluginVersion; + } + + @Override + public Long getDurationMillis() { + return durationMillis; + } + + public void setDurationMillis(Long durationMillis) { + this.durationMillis = durationMillis; + } + + @Override + public String getArtifactoryPrincipal() { + return artifactoryPrincipal; + } + + public void setArtifactoryPrincipal(String artifactoryPrincipal) { + this.artifactoryPrincipal = artifactoryPrincipal; + } + + @Override + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public String getVcsRevision() { + return vcsRevision; + } + + public void setVcsRevision(String vcsRevision) { + this.vcsRevision = vcsRevision; + } + + @Override + public String getVcsUrl() { + return vcsUrl; + } + + public void setVcsUrl(String vcsUrl) { + this.vcsUrl = vcsUrl; + } + + @Override + public List getVcs() { + return vcs; + } + + public void setVcs(List vcs) { + this.vcs = vcs; + } + + @Override + public LicenseControl getLicenseControl() { + return licenseControl; + } + + public void setLicenseControl(LicenseControl licenseControl) { + this.licenseControl = licenseControl; + } + + @Override + public BuildRetention getBuildRetention() { + return buildRetention; + } + + public void setBuildRetention(BuildRetention buildRetention) { + this.buildRetention = buildRetention; + } + + @Override + public List getModules() { + return modules; + } + + public void setModules(List modules) { + this.modules = modules; + } + + @Override + public Issues getIssues() { + return issues; + } + + public void setIssues(Issues issues) { + this.issues = issues; + } + + @Override + public Map getGovernance() { + return governance; + } + + public void setGovernance(Map governance) { + this.governance = governance; + } + + @Override + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } +} + +// Made with Bob diff --git a/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionRequestImpl.java b/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionRequestImpl.java new file mode 100644 index 00000000..1e583c01 --- /dev/null +++ b/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionRequestImpl.java @@ -0,0 +1,152 @@ +package org.jfrog.artifactory.client.model.impl; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.jfrog.artifactory.client.model.BuildPromotionRequest; + +import java.util.List; +import java.util.Map; + +/** + * Implementation of BuildPromotionRequest + * + * @author rnc + */ +public class BuildPromotionRequestImpl implements BuildPromotionRequest { + private String status; + private String comment; + @JsonProperty("ciUser") + private String ciUser; + private String timestamp; + @JsonProperty("dryRun") + private Boolean dryRun; + @JsonProperty("sourceRepo") + private String sourceRepo; + @JsonProperty("targetRepo") + private String targetRepo; + private Boolean copy; + private Boolean artifacts; + private Boolean dependencies; + private List scopes; + private Map properties; + @JsonProperty("failFast") + private Boolean failFast; + + @Override + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @Override + public String getCiUser() { + return ciUser; + } + + public void setCiUser(String ciUser) { + this.ciUser = ciUser; + } + + @Override + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + @Override + public Boolean getDryRun() { + return dryRun; + } + + public void setDryRun(Boolean dryRun) { + this.dryRun = dryRun; + } + + @Override + public String getSourceRepo() { + return sourceRepo; + } + + public void setSourceRepo(String sourceRepo) { + this.sourceRepo = sourceRepo; + } + + @Override + public String getTargetRepo() { + return targetRepo; + } + + public void setTargetRepo(String targetRepo) { + this.targetRepo = targetRepo; + } + + @Override + public Boolean getCopy() { + return copy; + } + + public void setCopy(Boolean copy) { + this.copy = copy; + } + + @Override + public Boolean getArtifacts() { + return artifacts; + } + + public void setArtifacts(Boolean artifacts) { + this.artifacts = artifacts; + } + + @Override + public Boolean getDependencies() { + return dependencies; + } + + public void setDependencies(Boolean dependencies) { + this.dependencies = dependencies; + } + + @Override + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + @Override + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + @Override + public Boolean getFailFast() { + return failFast; + } + + public void setFailFast(Boolean failFast) { + this.failFast = failFast; + } +} + +// Made with Bob diff --git a/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionResponseImpl.java b/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionResponseImpl.java new file mode 100644 index 00000000..36017c87 --- /dev/null +++ b/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildPromotionResponseImpl.java @@ -0,0 +1,26 @@ +package org.jfrog.artifactory.client.model.impl; + +import org.jfrog.artifactory.client.model.BuildPromotionResponse; +import org.jfrog.artifactory.client.model.PromotionMessage; + +import java.util.List; + +/** + * Implementation of BuildPromotionResponse + * + * @author rnc + */ +public class BuildPromotionResponseImpl implements BuildPromotionResponse { + private List messages; + + @Override + public List getMessages() { + return messages; + } + + public void setMessages(List messages) { + this.messages = messages; + } +} + +// Made with Bob diff --git a/services/src/main/java/org/jfrog/artifactory/client/model/impl/PromotionMessageImpl.java b/services/src/main/java/org/jfrog/artifactory/client/model/impl/PromotionMessageImpl.java new file mode 100644 index 00000000..b5e3b3a0 --- /dev/null +++ b/services/src/main/java/org/jfrog/artifactory/client/model/impl/PromotionMessageImpl.java @@ -0,0 +1,33 @@ +package org.jfrog.artifactory.client.model.impl; + +import org.jfrog.artifactory.client.model.PromotionMessage; + +/** + * Implementation of PromotionMessage + * + * @author rnc + */ +public class PromotionMessageImpl implements PromotionMessage { + private String level; + private String message; + + @Override + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} + +// Made with Bob diff --git a/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java b/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java index c74668a6..d84de0b4 100644 --- a/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java +++ b/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java @@ -3,19 +3,24 @@ import org.apache.commons.lang3.StringUtils; import org.jfrog.artifactory.client.model.AllBuilds; import org.jfrog.artifactory.client.model.Build; +import org.jfrog.artifactory.client.model.BuildInfo; import org.jfrog.artifactory.client.model.BuildNumber; +import org.jfrog.artifactory.client.model.BuildPromotionResponse; import org.jfrog.artifactory.client.model.BuildRuns; +import org.jfrog.artifactory.client.model.PromotionMessage; +import org.jfrog.artifactory.client.model.impl.BuildPromotionRequestImpl; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.List; import java.util.Map; import static org.jfrog.artifactory.client.Utils.createBuildBody; +import static org.jfrog.artifactory.client.Utils.createBuildInfo; import static org.jfrog.artifactory.client.Utils.uploadBuild; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.testng.Assert.*; /** * @author yahavi @@ -23,6 +28,13 @@ public class BuildsTests extends ArtifactoryTestsBase { private static final String BUILDS_API = "/api/build"; + private static final String TEST_BUILD_NAME = "TestBuild"; + private static final String TEST_BUILD_NUMBER = "13"; + private static final String UPLOAD_TEST_BUILD_NAME = "UploadTestBuild"; + private static final String UPLOAD_TEST_BUILD_NUMBER = "100"; + private static final String PROMOTE_TEST_BUILD_NAME = "PromoteTestBuild"; + private static final String PROMOTE_TEST_BUILD_NUMBER = "200"; + private Map buildBody; @BeforeClass @@ -67,6 +79,69 @@ public void testGetBuildRuns() throws IOException { assertTrue(StringUtils.isNotBlank(buildNumber.getStarted())); } + @Test + public void testUploadBuild() throws IOException { + // Create a new build info + BuildInfo buildInfo = createBuildInfo(); + + // Modify the build name and number to avoid conflicts + ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setName(UPLOAD_TEST_BUILD_NAME); + ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setNumber(UPLOAD_TEST_BUILD_NUMBER); + + // Upload the build + artifactory.builds().uploadBuild(buildInfo); + + // Verify the build was uploaded by retrieving it + BuildRuns buildRuns = artifactory.builds().getBuildRuns(UPLOAD_TEST_BUILD_NAME); + assertNotNull(buildRuns); + + // Check that our build number exists + BuildNumber buildNumber = buildRuns.getBuildsNumbers().stream() + .filter(bn -> StringUtils.equals(bn.getUri(), "/" + UPLOAD_TEST_BUILD_NUMBER)) + .findAny().orElse(null); + assertNotNull(buildNumber, "Build number " + UPLOAD_TEST_BUILD_NUMBER + " was not found after upload"); + } + + @Test + public void testPromoteBuild() throws IOException { + // First upload a build to promote + BuildInfo buildInfo = createBuildInfo(); + ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setName(PROMOTE_TEST_BUILD_NAME); + ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setNumber(PROMOTE_TEST_BUILD_NUMBER); + artifactory.builds().uploadBuild(buildInfo); + + // Create promotion request + BuildPromotionRequestImpl promotionRequest = new BuildPromotionRequestImpl(); + promotionRequest.setStatus("Released"); + promotionRequest.setComment("Promoted by automated test"); + promotionRequest.setCiUser("testUser"); + promotionRequest.setTimestamp(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(System.currentTimeMillis())); + promotionRequest.setCopy(false); + promotionRequest.setArtifacts(true); + promotionRequest.setDependencies(false); + promotionRequest.setFailFast(true); + promotionRequest.setDryRun(true); // Use dry run to avoid needing actual artifacts + + // Promote the build + BuildPromotionResponse response = artifactory.builds().promoteBuild( + PROMOTE_TEST_BUILD_NAME, + PROMOTE_TEST_BUILD_NUMBER, + promotionRequest + ); + + // Verify response + assertNotNull(response); + assertNotNull(response.getMessages()); + + // In dry run mode, we should get messages about what would happen + if (!response.getMessages().isEmpty()) { + for (PromotionMessage message : response.getMessages()) { + assertNotNull(message.getLevel()); + assertNotNull(message.getMessage()); + } + } + } + private String getExpectedBuildName() { return (String) buildBody.get("name"); } diff --git a/services/src/test/java/org/jfrog/artifactory/client/Utils.java b/services/src/test/java/org/jfrog/artifactory/client/Utils.java index 5db481b1..23ca5f57 100644 --- a/services/src/test/java/org/jfrog/artifactory/client/Utils.java +++ b/services/src/test/java/org/jfrog/artifactory/client/Utils.java @@ -5,6 +5,8 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.jfrog.artifactory.client.impl.ArtifactoryRequestImpl; +import org.jfrog.artifactory.client.model.BuildInfo; +import org.jfrog.artifactory.client.model.impl.BuildInfoImpl; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -40,4 +42,17 @@ public static Map createBuildBody() { } return new HashMap<>(); } + + public static BuildInfo createBuildInfo() { + String buildStarted = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(System.currentTimeMillis()); + try { + String buildInfoJson = IOUtils.toString(Utils.class.getResourceAsStream("/build.json"), StandardCharsets.UTF_8); + buildInfoJson = StringUtils.replace(buildInfoJson, "{build.start.time}", buildStarted); + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(buildInfoJson, BuildInfoImpl.class); + } catch (IOException e) { + fail(ExceptionUtils.getRootCauseMessage(e)); + } + return null; + } } From 7c17b7704b139ae467e0806020cfae460dc529d8 Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Tue, 9 Jun 2026 16:27:00 +0100 Subject: [PATCH 2/2] Migrate to use official build-info API --- .../org/jfrog/artifactory/client/Builds.java | 14 +- .../artifactory/client/model/BuildInfo.java | 248 ------------------ build.gradle | 1 + .../artifactory/client/impl/BuildsImpl.java | 10 +- .../client/model/impl/BuildInfoImpl.java | 218 --------------- .../jfrog/artifactory/client/BuildsTests.java | 29 +- .../org/jfrog/artifactory/client/Utils.java | 7 +- 7 files changed, 30 insertions(+), 497 deletions(-) delete mode 100644 api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java delete mode 100644 services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java diff --git a/api/src/main/java/org/jfrog/artifactory/client/Builds.java b/api/src/main/java/org/jfrog/artifactory/client/Builds.java index 4d0651fa..e32d2094 100644 --- a/api/src/main/java/org/jfrog/artifactory/client/Builds.java +++ b/api/src/main/java/org/jfrog/artifactory/client/Builds.java @@ -1,10 +1,10 @@ package org.jfrog.artifactory.client; import org.jfrog.artifactory.client.model.AllBuilds; -import org.jfrog.artifactory.client.model.BuildInfo; import org.jfrog.artifactory.client.model.BuildPromotionRequest; import org.jfrog.artifactory.client.model.BuildPromotionResponse; import org.jfrog.artifactory.client.model.BuildRuns; +import org.jfrog.build.api.Build; import java.io.IOException; @@ -17,21 +17,21 @@ public interface Builds { BuildRuns getBuildRuns(String buildName) throws IOException; /** - * Upload a build to Artifactory + * Upload a build to Artifactory using the official build-info API * - * @param buildInfo the build info + * @param build the build info from org.jfrog.build.api.Build * @throws IOException if the upload fails */ - void uploadBuild(BuildInfo buildInfo) throws IOException; + void uploadBuild(Build build) throws IOException; /** - * Upload a build to Artifactory with a project parameter + * Upload a build to Artifactory with a project parameter using the official build-info API * - * @param buildInfo the build info + * @param build the build info from org.jfrog.build.api.Build * @param project the project name to limit the build to * @throws IOException if the upload fails */ - void uploadBuild(BuildInfo buildInfo, String project) throws IOException; + void uploadBuild(Build build, String project) throws IOException; /** * Promote a build in Artifactory diff --git a/api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java b/api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java deleted file mode 100644 index 63ab15d4..00000000 --- a/api/src/main/java/org/jfrog/artifactory/client/model/BuildInfo.java +++ /dev/null @@ -1,248 +0,0 @@ -package org.jfrog.artifactory.client.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.util.List; -import java.util.Map; - -/** - * Build Info structure for uploading to Artifactory - * - * @author rnc - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public interface BuildInfo { - /** - * Build Info schema version - * @return the version - */ - String getVersion(); - - /** - * Build name - * @return the build name - */ - String getName(); - - /** - * Build number - * @return the build number - */ - String getNumber(); - - /** - * Build type (MAVEN, GRADLE, ANT, IVY, GENERIC) - * @return the build type - */ - String getType(); - - /** - * Build agent information (build tool) - * @return the build agent - */ - BuildAgent getBuildAgent(); - - /** - * CI agent information (CI server) - * @return the agent - */ - Agent getAgent(); - - /** - * Build start time in ISO 8601 format (yyyy-MM-dd'T'HH:mm:ss.SSSZ) - * @return the start time - */ - String getStarted(); - - /** - * Artifactory plugin version - * @return the plugin version - */ - String getArtifactoryPluginVersion(); - - /** - * Build duration in milliseconds - * @return the duration - */ - Long getDurationMillis(); - - /** - * Artifactory principal (the Artifactory user used for deployment) - * @return the principal - */ - String getArtifactoryPrincipal(); - - /** - * CI server URL - * @return the URL - */ - String getUrl(); - - /** - * VCS revision - * @return the VCS revision - */ - String getVcsRevision(); - - /** - * VCS URL - * @return the VCS URL - */ - String getVcsUrl(); - - /** - * VCS information list - * @return the VCS list - */ - List getVcs(); - - /** - * License control settings - * @return the license control - */ - LicenseControl getLicenseControl(); - - /** - * Build retention settings - * @return the build retention - */ - BuildRetention getBuildRetention(); - - /** - * Build modules - * @return the modules - */ - List getModules(); - - /** - * Issues information - * @return the issues - */ - Issues getIssues(); - - /** - * Governance information - * @return the governance - */ - Map getGovernance(); - - /** - * Environment variables and properties - * @return the properties - */ - Map getProperties(); - - /** - * Build agent (build tool) information - */ - interface BuildAgent { - String getName(); - String getVersion(); - } - - /** - * CI agent (CI server) information - */ - interface Agent { - String getName(); - String getVersion(); - } - - /** - * VCS information - */ - interface VcsInfo { - String getRevision(); - String getMessage(); - String getBranch(); - String getUrl(); - } - - /** - * License control settings - */ - interface LicenseControl { - Boolean getRunChecks(); - Boolean getIncludePublishedArtifacts(); - Boolean getAutoDiscover(); - String getScopesList(); - String getLicenseViolationsRecipientsList(); - } - - /** - * Build retention settings - */ - interface BuildRetention { - Boolean getDeleteBuildArtifacts(); - Integer getCount(); - Long getMinimumBuildDate(); - List getBuildNumbersNotToBeDiscarded(); - } - - /** - * Build module - */ - interface BuildModule { - Map getProperties(); - String getId(); - String getType(); - List getArtifacts(); - List getDependencies(); - } - - /** - * Build artifact - */ - interface Artifact { - String getType(); - String getSha1(); - String getSha256(); - String getMd5(); - String getName(); - String getPath(); - String getOriginalDeploymentRepo(); - } - - /** - * Build dependency - */ - interface Dependency { - String getType(); - String getSha1(); - String getSha256(); - String getMd5(); - String getId(); - List getScopes(); - List> getRequestedBy(); - } - - /** - * Issues information - */ - interface Issues { - Tracker getTracker(); - Boolean getAggregateBuildIssues(); - String getAggregationBuildStatus(); - List getAffectedIssues(); - } - - /** - * Issue tracker information - */ - interface Tracker { - String getName(); - String getVersion(); - } - - /** - * Affected issue - */ - interface AffectedIssue { - String getKey(); - String getUrl(); - String getSummary(); - Boolean getAggregated(); - } -} - -// Made with Bob diff --git a/build.gradle b/build.gradle index a3f852f1..80db9e4d 100644 --- a/build.gradle +++ b/build.gradle @@ -86,6 +86,7 @@ subprojects { implementation 'com.fasterxml.jackson.core:jackson-databind:2.21.1' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.21' api 'org.jfrog.filespecs:file-specs-java:1.1.2' + api 'org.jfrog.buildinfo:build-info-api:2.+' } task sourcesJar(type: Jar, dependsOn: classes) { diff --git a/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java b/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java index 49044029..0f9d0447 100644 --- a/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java +++ b/services/src/main/java/org/jfrog/artifactory/client/impl/BuildsImpl.java @@ -5,13 +5,13 @@ import org.jfrog.artifactory.client.Builds; import org.jfrog.artifactory.client.impl.util.Util; import org.jfrog.artifactory.client.model.AllBuilds; -import org.jfrog.artifactory.client.model.BuildInfo; import org.jfrog.artifactory.client.model.BuildPromotionRequest; import org.jfrog.artifactory.client.model.BuildPromotionResponse; import org.jfrog.artifactory.client.model.BuildRuns; import org.jfrog.artifactory.client.model.impl.AllBuildsImpl; import org.jfrog.artifactory.client.model.impl.BuildPromotionResponseImpl; import org.jfrog.artifactory.client.model.impl.BuildRunsImpl; +import org.jfrog.build.api.Build; import java.io.IOException; import java.util.HashMap; @@ -40,12 +40,12 @@ public BuildRuns getBuildRuns(String buildName) throws IOException { } @Override - public void uploadBuild(BuildInfo buildInfo) throws IOException { - uploadBuild(buildInfo, null); + public void uploadBuild(Build build) throws IOException { + uploadBuild(build, null); } @Override - public void uploadBuild(BuildInfo buildInfo, String project) throws IOException { + public void uploadBuild(Build build, String project) throws IOException { String apiPath = getBuilderApi(); if (project != null && !project.isEmpty()) { apiPath += "?project=" + project; @@ -53,7 +53,7 @@ public void uploadBuild(BuildInfo buildInfo, String project) throws IOException Map headers = new HashMap<>(); artifactory.put(apiPath, ContentType.APPLICATION_JSON, - Util.getStringFromObject(buildInfo), headers, null, -1, + Util.getStringFromObject(build), headers, null, -1, String.class, null); } diff --git a/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java b/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java deleted file mode 100644 index 087491c3..00000000 --- a/services/src/main/java/org/jfrog/artifactory/client/model/impl/BuildInfoImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -package org.jfrog.artifactory.client.model.impl; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.jfrog.artifactory.client.model.BuildInfo; - -import java.util.List; -import java.util.Map; - -/** - * Implementation of BuildInfo - * - * @author rnc - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class BuildInfoImpl implements BuildInfo { - private String version; - private String name; - private String number; - private String type; - private BuildAgent buildAgent; - private Agent agent; - private String started; - private String artifactoryPluginVersion; - private Long durationMillis; - private String artifactoryPrincipal; - private String url; - private String vcsRevision; - private String vcsUrl; - private List vcs; - private LicenseControl licenseControl; - private BuildRetention buildRetention; - private List modules; - private Issues issues; - private Map governance; - private Map properties; - - @Override - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public String getNumber() { - return number; - } - - public void setNumber(String number) { - this.number = number; - } - - @Override - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public BuildAgent getBuildAgent() { - return buildAgent; - } - - public void setBuildAgent(BuildAgent buildAgent) { - this.buildAgent = buildAgent; - } - - @Override - public Agent getAgent() { - return agent; - } - - public void setAgent(Agent agent) { - this.agent = agent; - } - - @Override - public String getStarted() { - return started; - } - - public void setStarted(String started) { - this.started = started; - } - - @Override - public String getArtifactoryPluginVersion() { - return artifactoryPluginVersion; - } - - public void setArtifactoryPluginVersion(String artifactoryPluginVersion) { - this.artifactoryPluginVersion = artifactoryPluginVersion; - } - - @Override - public Long getDurationMillis() { - return durationMillis; - } - - public void setDurationMillis(Long durationMillis) { - this.durationMillis = durationMillis; - } - - @Override - public String getArtifactoryPrincipal() { - return artifactoryPrincipal; - } - - public void setArtifactoryPrincipal(String artifactoryPrincipal) { - this.artifactoryPrincipal = artifactoryPrincipal; - } - - @Override - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @Override - public String getVcsRevision() { - return vcsRevision; - } - - public void setVcsRevision(String vcsRevision) { - this.vcsRevision = vcsRevision; - } - - @Override - public String getVcsUrl() { - return vcsUrl; - } - - public void setVcsUrl(String vcsUrl) { - this.vcsUrl = vcsUrl; - } - - @Override - public List getVcs() { - return vcs; - } - - public void setVcs(List vcs) { - this.vcs = vcs; - } - - @Override - public LicenseControl getLicenseControl() { - return licenseControl; - } - - public void setLicenseControl(LicenseControl licenseControl) { - this.licenseControl = licenseControl; - } - - @Override - public BuildRetention getBuildRetention() { - return buildRetention; - } - - public void setBuildRetention(BuildRetention buildRetention) { - this.buildRetention = buildRetention; - } - - @Override - public List getModules() { - return modules; - } - - public void setModules(List modules) { - this.modules = modules; - } - - @Override - public Issues getIssues() { - return issues; - } - - public void setIssues(Issues issues) { - this.issues = issues; - } - - @Override - public Map getGovernance() { - return governance; - } - - public void setGovernance(Map governance) { - this.governance = governance; - } - - @Override - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } -} - -// Made with Bob diff --git a/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java b/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java index d84de0b4..4799ec48 100644 --- a/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java +++ b/services/src/test/java/org/jfrog/artifactory/client/BuildsTests.java @@ -2,13 +2,12 @@ import org.apache.commons.lang3.StringUtils; import org.jfrog.artifactory.client.model.AllBuilds; -import org.jfrog.artifactory.client.model.Build; -import org.jfrog.artifactory.client.model.BuildInfo; import org.jfrog.artifactory.client.model.BuildNumber; import org.jfrog.artifactory.client.model.BuildPromotionResponse; import org.jfrog.artifactory.client.model.BuildRuns; import org.jfrog.artifactory.client.model.PromotionMessage; import org.jfrog.artifactory.client.model.impl.BuildPromotionRequestImpl; +import org.jfrog.build.api.Build; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -17,8 +16,8 @@ import java.util.List; import java.util.Map; +import static org.jfrog.artifactory.client.Utils.createBuild; import static org.jfrog.artifactory.client.Utils.createBuildBody; -import static org.jfrog.artifactory.client.Utils.createBuildInfo; import static org.jfrog.artifactory.client.Utils.uploadBuild; import static org.testng.Assert.*; @@ -50,12 +49,12 @@ public void testGetAllBuilds() throws Exception { assertNotNull(allBuilds); assertTrue(StringUtils.contains(allBuilds.getUri(), BUILDS_API), allBuilds.getUri() + " is expected to contains '" + BUILDS_API + "'"); - List actualBuilds = allBuilds.getBuilds(); + List actualBuilds = allBuilds.getBuilds(); assertNotNull(actualBuilds); // Assert build uri "/TestBuild" exist String expectedBuildUri = "/" + getExpectedBuildName(); - Build actualBuild = actualBuilds.stream() + org.jfrog.artifactory.client.model.Build actualBuild = actualBuilds.stream() .filter(build -> StringUtils.equals(build.getUri(), expectedBuildUri)) .findAny().orElse(null); assertNotNull(actualBuild, "Build Uri " + expectedBuildUri + " does not exist in [" + actualBuilds + "]"); @@ -81,15 +80,15 @@ public void testGetBuildRuns() throws IOException { @Test public void testUploadBuild() throws IOException { - // Create a new build info - BuildInfo buildInfo = createBuildInfo(); + // Create a new build using the build-info API + Build build = createBuild(); // Modify the build name and number to avoid conflicts - ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setName(UPLOAD_TEST_BUILD_NAME); - ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setNumber(UPLOAD_TEST_BUILD_NUMBER); + build.setName(UPLOAD_TEST_BUILD_NAME); + build.setNumber(UPLOAD_TEST_BUILD_NUMBER); // Upload the build - artifactory.builds().uploadBuild(buildInfo); + artifactory.builds().uploadBuild(build); // Verify the build was uploaded by retrieving it BuildRuns buildRuns = artifactory.builds().getBuildRuns(UPLOAD_TEST_BUILD_NAME); @@ -104,11 +103,11 @@ public void testUploadBuild() throws IOException { @Test public void testPromoteBuild() throws IOException { - // First upload a build to promote - BuildInfo buildInfo = createBuildInfo(); - ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setName(PROMOTE_TEST_BUILD_NAME); - ((org.jfrog.artifactory.client.model.impl.BuildInfoImpl) buildInfo).setNumber(PROMOTE_TEST_BUILD_NUMBER); - artifactory.builds().uploadBuild(buildInfo); + // First upload a build to promote using the build-info API + Build build = createBuild(); + build.setName(PROMOTE_TEST_BUILD_NAME); + build.setNumber(PROMOTE_TEST_BUILD_NUMBER); + artifactory.builds().uploadBuild(build); // Create promotion request BuildPromotionRequestImpl promotionRequest = new BuildPromotionRequestImpl(); diff --git a/services/src/test/java/org/jfrog/artifactory/client/Utils.java b/services/src/test/java/org/jfrog/artifactory/client/Utils.java index 23ca5f57..b565871a 100644 --- a/services/src/test/java/org/jfrog/artifactory/client/Utils.java +++ b/services/src/test/java/org/jfrog/artifactory/client/Utils.java @@ -5,8 +5,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.jfrog.artifactory.client.impl.ArtifactoryRequestImpl; -import org.jfrog.artifactory.client.model.BuildInfo; -import org.jfrog.artifactory.client.model.impl.BuildInfoImpl; +import org.jfrog.build.api.Build; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -43,13 +42,13 @@ public static Map createBuildBody() { return new HashMap<>(); } - public static BuildInfo createBuildInfo() { + public static Build createBuild() { String buildStarted = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(System.currentTimeMillis()); try { String buildInfoJson = IOUtils.toString(Utils.class.getResourceAsStream("/build.json"), StandardCharsets.UTF_8); buildInfoJson = StringUtils.replace(buildInfoJson, "{build.start.time}", buildStarted); ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(buildInfoJson, BuildInfoImpl.class); + return mapper.readValue(buildInfoJson, Build.class); } catch (IOException e) { fail(ExceptionUtils.getRootCauseMessage(e)); }