Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add original deployment repository field #807

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions build-info-api/src/main/java/org/jfrog/build/api/Artifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class Artifact extends BaseBuildFileBean {

private String name;
private String originalDeploymentRepo;

/**
* Returns the name of the artifact
Expand All @@ -29,6 +30,24 @@ public void setName(String name) {
this.name = name;
}

/**
* Returns the original deployment repository of the artifact
*
* @return repository name
*/
public String getOriginalDeploymentRepo() {
return originalDeploymentRepo;
}

/**
* Sets the original deployment repository of the artifact
*
* @param originalDeploymentRepo repository name
*/
public void setOriginalDeploymentRepo(String originalDeploymentRepo) {
this.originalDeploymentRepo = originalDeploymentRepo;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ArtifactBuilder {
private String md5;
private String remotePath;
private Properties properties;
private String originalDeploymentRepo;

public ArtifactBuilder(String name) {
this.name = name;
Expand All @@ -43,6 +44,7 @@ public Artifact build() {
artifact.setRemotePath(remotePath);
artifact.setLocalPath(localPath);
artifact.setProperties(properties);
artifact.setOriginalDeploymentRepo(originalDeploymentRepo);
return artifact;
}

Expand Down Expand Up @@ -134,6 +136,17 @@ public ArtifactBuilder properties(Properties properties) {
return this;
}

/**
* Sets the originalDeploymentRepo of the artifact
*
* @param originalDeploymentRepo Artifact original deployment repository
* @return Builder instance
*/
public ArtifactBuilder originalDeploymentRepo(String originalDeploymentRepo) {
this.originalDeploymentRepo = originalDeploymentRepo;
return this;
}

/**
* Adds the given property to the properties object
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class Artifact extends BaseBuildFileBean {

private String name;
private String originalDeploymentRepo;

/**
* Returns the name of the artifact
Expand All @@ -27,6 +28,24 @@ public void setName(String name) {
this.name = name;
}

/**
* Returns the original deployment repository of the artifact
*
* @return repository name
*/
public String getOriginalDeploymentRepo() {
return originalDeploymentRepo;
}

/**
* Sets the original deployment repository of the artifact
*
* @param originalDeploymentRepo repository name
*/
public void setOriginalDeploymentRepo(String originalDeploymentRepo) {
this.originalDeploymentRepo = originalDeploymentRepo;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -59,6 +78,7 @@ public org.jfrog.build.api.Artifact ToBuildArtifact() {
result.setSha1(sha1);
result.setRemotePath(remotePath);
result.setProperties(getProperties());
result.setOriginalDeploymentRepo(originalDeploymentRepo);
return result;
}

Expand All @@ -71,6 +91,7 @@ public static Artifact ToBuildInfoArtifact(org.jfrog.build.api.Artifact artifact
result.setSha1(artifact.getSha1());
result.setRemotePath(artifact.getRemotePath());
result.setProperties(artifact.getProperties());
result.setOriginalDeploymentRepo(artifact.getOriginalDeploymentRepo());
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void testEmptyConstructor() {
assertNull(artifact.getSha1(), "Artifact SHA1 checksum should have not been initialized.");
assertNull(artifact.getSha256(), "Artifact SHA256 checksum should have not been initialized.");
assertNull(artifact.getMd5(), "Artifact MD5 checksum should have not been initialized.");
assertNull(artifact.getOriginalDeploymentRepo(), "Artifact original deployment repository should have not been initialized.");
}

/**
Expand All @@ -43,6 +44,7 @@ public void testSetters() {
String md5 = "gog";
String localPath = "blip";
String remotePath = "blop";
String originalDeploymentRepository = "repo";
Properties properties = new Properties();

Artifact artifact = new Artifact();
Expand All @@ -54,6 +56,7 @@ public void testSetters() {
artifact.setLocalPath(localPath);
artifact.setRemotePath(remotePath);
artifact.setProperties(properties);
artifact.setOriginalDeploymentRepo(originalDeploymentRepository);

Assert.assertEquals(artifact.getName(), name, "Unexpected artifact name.");
Assert.assertEquals(artifact.getType(), type, "Unexpected artifact type.");
Expand All @@ -63,6 +66,7 @@ public void testSetters() {
Assert.assertEquals(artifact.getLocalPath(), localPath, "Unexpected artifact local path.");
Assert.assertEquals(artifact.getRemotePath(), remotePath, "Unexpected artifact remote path.");
Assert.assertEquals(artifact.getProperties(), properties, "Unexpected artifact properties.");
Assert.assertEquals(artifact.getOriginalDeploymentRepo(),originalDeploymentRepository, "Unexpected artifact original deployment repository.");
}

public void testEqualsAndHash() {
Expand All @@ -75,6 +79,7 @@ public void testEqualsAndHash() {
artifact1.setSha1("111");
artifact1.setSha256("11111");
artifact1.setMd5("1111");
artifact1.setOriginalDeploymentRepo("repo");
artifact1.setProperties(properties);

Artifact artifact2 = new Artifact();
Expand All @@ -83,6 +88,7 @@ public void testEqualsAndHash() {
artifact2.setSha1("111");
artifact2.setSha256("11111");
artifact2.setMd5("1111");
artifact2.setOriginalDeploymentRepo("repo");
artifact2.setProperties(properties);

Artifact artifact3 = new Artifact();
Expand All @@ -91,6 +97,7 @@ public void testEqualsAndHash() {
artifact3.setSha1("1113");
artifact3.setSha256("11133");
artifact3.setMd5("11113");
artifact3.setOriginalDeploymentRepo("diff-repo");
artifact3.setProperties(properties);

Assert.assertEquals(artifact1, artifact2, "Expected equals == true for equivalent artifacts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class BuildInfoMavenBuilderTest {
public static final String SHA1 = "e4e264c711ae7ab54f26542f0dd09a43b93fa12c";
public static final String SHA2 = "yyyy23029162f3b2dc51f512cb64bce8cb6913ed6e540f23ec567d898f60yyyy";
public static final String MD5 = "d9303a42c66c2824fd6ba0f75e335294";
public static final String DEPLOY_REPO = "repo";

/**
* Validates the build values when using the defaults
Expand Down Expand Up @@ -163,12 +164,12 @@ public void testDuplicateModules() {
*/
public void testDuplicateModuleArtifacts() {
ModuleBuilder module1 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
module1.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module1.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module1.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());
module1.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());

ModuleBuilder module2 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
module2.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module2.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module2.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());
module2.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());

BuildInfoMavenBuilder builder = new BuildInfoMavenBuilder("test").number("4").started("test");
builder.addModule(module1.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class AccessManagerTest extends IntegrationTestsBase {
@BeforeClass
@Override
public void init() throws IOException {
super.init();
super.init(true);
String accessUrl = getPlatformUrl() + "access";
accessManager = new AccessManager(accessUrl, getAdminToken(), getLog());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public static Log getLog() {
return log;
}

@BeforeClass
public void init() throws IOException {
public void init(boolean isAccessTest) throws IOException {
Properties props = new Properties();
// This file is not in GitHub. Create your own in src/test/resources or use environment variables.
InputStream inputStream = this.getClass().getResourceAsStream("/artifactory-bi.properties");
Expand All @@ -69,8 +68,13 @@ public void init() throws IOException {
props.load(inputStream);
inputStream.close();
}
String testPort = "8081";
// Change the port variable only if isAccessTest is true
if (isAccessTest) {
testPort = "8082";
}

platformUrl = readParam(props, "url", "http://127.0.0.1:8081");
platformUrl = readParam(props, "url", "http://127.0.0.1:" + testPort);
if (!platformUrl.endsWith("/")) {
platformUrl += "/";
}
Expand All @@ -92,6 +96,16 @@ public void init() throws IOException {
}
}

@BeforeClass
public void init() throws IOException {
init(false);
}

@BeforeClass
public void accessInit() throws IOException {
init(true);
}

@AfterClass
protected void terminate() throws IOException {
// Delete the virtual first.
Expand Down
Loading