Skip to content

Commit 13afda7

Browse files
authored
Add original deployment repository field (#807)
1 parent ff71e32 commit 13afda7

File tree

7 files changed

+83
-8
lines changed

7 files changed

+83
-8
lines changed

build-info-api/src/main/java/org/jfrog/build/api/Artifact.java

+19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public class Artifact extends BaseBuildFileBean {
1111

1212
private String name;
13+
private String originalDeploymentRepo;
1314

1415
/**
1516
* Returns the name of the artifact
@@ -29,6 +30,24 @@ public void setName(String name) {
2930
this.name = name;
3031
}
3132

33+
/**
34+
* Returns the original deployment repository of the artifact
35+
*
36+
* @return repository name
37+
*/
38+
public String getOriginalDeploymentRepo() {
39+
return originalDeploymentRepo;
40+
}
41+
42+
/**
43+
* Sets the original deployment repository of the artifact
44+
*
45+
* @param originalDeploymentRepo repository name
46+
*/
47+
public void setOriginalDeploymentRepo(String originalDeploymentRepo) {
48+
this.originalDeploymentRepo = originalDeploymentRepo;
49+
}
50+
3251
@Override
3352
public boolean equals(Object o) {
3453
if (this == o) {

build-info-extractor/src/main/java/org/jfrog/build/extractor/builder/ArtifactBuilder.java

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class ArtifactBuilder {
2020
private String md5;
2121
private String remotePath;
2222
private Properties properties;
23+
private String originalDeploymentRepo;
2324

2425
public ArtifactBuilder(String name) {
2526
this.name = name;
@@ -43,6 +44,7 @@ public Artifact build() {
4344
artifact.setRemotePath(remotePath);
4445
artifact.setLocalPath(localPath);
4546
artifact.setProperties(properties);
47+
artifact.setOriginalDeploymentRepo(originalDeploymentRepo);
4648
return artifact;
4749
}
4850

@@ -134,6 +136,17 @@ public ArtifactBuilder properties(Properties properties) {
134136
return this;
135137
}
136138

139+
/**
140+
* Sets the originalDeploymentRepo of the artifact
141+
*
142+
* @param originalDeploymentRepo Artifact original deployment repository
143+
* @return Builder instance
144+
*/
145+
public ArtifactBuilder originalDeploymentRepo(String originalDeploymentRepo) {
146+
this.originalDeploymentRepo = originalDeploymentRepo;
147+
return this;
148+
}
149+
137150
/**
138151
* Adds the given property to the properties object
139152
*

build-info-extractor/src/main/java/org/jfrog/build/extractor/ci/Artifact.java

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
public class Artifact extends BaseBuildFileBean {
99

1010
private String name;
11+
private String originalDeploymentRepo;
1112

1213
/**
1314
* Returns the name of the artifact
@@ -27,6 +28,24 @@ public void setName(String name) {
2728
this.name = name;
2829
}
2930

31+
/**
32+
* Returns the original deployment repository of the artifact
33+
*
34+
* @return repository name
35+
*/
36+
public String getOriginalDeploymentRepo() {
37+
return originalDeploymentRepo;
38+
}
39+
40+
/**
41+
* Sets the original deployment repository of the artifact
42+
*
43+
* @param originalDeploymentRepo repository name
44+
*/
45+
public void setOriginalDeploymentRepo(String originalDeploymentRepo) {
46+
this.originalDeploymentRepo = originalDeploymentRepo;
47+
}
48+
3049
@Override
3150
public boolean equals(Object o) {
3251
if (this == o) {
@@ -59,6 +78,7 @@ public org.jfrog.build.api.Artifact ToBuildArtifact() {
5978
result.setSha1(sha1);
6079
result.setRemotePath(remotePath);
6180
result.setProperties(getProperties());
81+
result.setOriginalDeploymentRepo(originalDeploymentRepo);
6282
return result;
6383
}
6484

@@ -71,6 +91,7 @@ public static Artifact ToBuildInfoArtifact(org.jfrog.build.api.Artifact artifact
7191
result.setSha1(artifact.getSha1());
7292
result.setRemotePath(artifact.getRemotePath());
7393
result.setProperties(artifact.getProperties());
94+
result.setOriginalDeploymentRepo(artifact.getOriginalDeploymentRepo());
7495
return result;
7596
}
7697
}

build-info-extractor/src/test/java/org/jfrog/build/extractor/ci/ArtifactTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public void testEmptyConstructor() {
3030
assertNull(artifact.getSha1(), "Artifact SHA1 checksum should have not been initialized.");
3131
assertNull(artifact.getSha256(), "Artifact SHA256 checksum should have not been initialized.");
3232
assertNull(artifact.getMd5(), "Artifact MD5 checksum should have not been initialized.");
33+
assertNull(artifact.getOriginalDeploymentRepo(), "Artifact original deployment repository should have not been initialized.");
3334
}
3435

3536
/**
@@ -43,6 +44,7 @@ public void testSetters() {
4344
String md5 = "gog";
4445
String localPath = "blip";
4546
String remotePath = "blop";
47+
String originalDeploymentRepository = "repo";
4648
Properties properties = new Properties();
4749

4850
Artifact artifact = new Artifact();
@@ -54,6 +56,7 @@ public void testSetters() {
5456
artifact.setLocalPath(localPath);
5557
artifact.setRemotePath(remotePath);
5658
artifact.setProperties(properties);
59+
artifact.setOriginalDeploymentRepo(originalDeploymentRepository);
5760

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

6872
public void testEqualsAndHash() {
@@ -75,6 +79,7 @@ public void testEqualsAndHash() {
7579
artifact1.setSha1("111");
7680
artifact1.setSha256("11111");
7781
artifact1.setMd5("1111");
82+
artifact1.setOriginalDeploymentRepo("repo");
7883
artifact1.setProperties(properties);
7984

8085
Artifact artifact2 = new Artifact();
@@ -83,6 +88,7 @@ public void testEqualsAndHash() {
8388
artifact2.setSha1("111");
8489
artifact2.setSha256("11111");
8590
artifact2.setMd5("1111");
91+
artifact2.setOriginalDeploymentRepo("repo");
8692
artifact2.setProperties(properties);
8793

8894
Artifact artifact3 = new Artifact();
@@ -91,6 +97,7 @@ public void testEqualsAndHash() {
9197
artifact3.setSha1("1113");
9298
artifact3.setSha256("11133");
9399
artifact3.setMd5("11113");
100+
artifact3.setOriginalDeploymentRepo("diff-repo");
94101
artifact3.setProperties(properties);
95102

96103
Assert.assertEquals(artifact1, artifact2, "Expected equals == true for equivalent artifacts");

build-info-extractor/src/test/java/org/jfrog/build/extractor/ci/BuildInfoMavenBuilderTest.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class BuildInfoMavenBuilderTest {
3434
public static final String SHA1 = "e4e264c711ae7ab54f26542f0dd09a43b93fa12c";
3535
public static final String SHA2 = "yyyy23029162f3b2dc51f512cb64bce8cb6913ed6e540f23ec567d898f60yyyy";
3636
public static final String MD5 = "d9303a42c66c2824fd6ba0f75e335294";
37+
public static final String DEPLOY_REPO = "repo";
3738

3839
/**
3940
* Validates the build values when using the defaults
@@ -163,12 +164,12 @@ public void testDuplicateModules() {
163164
*/
164165
public void testDuplicateModuleArtifacts() {
165166
ModuleBuilder module1 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
166-
module1.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
167-
module1.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).build());
167+
module1.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());
168+
module1.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());
168169

169170
ModuleBuilder module2 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
170-
module2.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
171-
module2.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).build());
171+
module2.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());
172+
module2.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).originalDeploymentRepo(DEPLOY_REPO).build());
172173

173174
BuildInfoMavenBuilder builder = new BuildInfoMavenBuilder("test").number("4").started("test");
174175
builder.addModule(module1.build());

build-info-extractor/src/test/java/org/jfrog/build/extractor/clientConfiguration/client/AccessManagerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class AccessManagerTest extends IntegrationTestsBase {
4545
@BeforeClass
4646
@Override
4747
public void init() throws IOException {
48-
super.init();
48+
super.init(true);
4949
String accessUrl = getPlatformUrl() + "access";
5050
accessManager = new AccessManager(accessUrl, getAdminToken(), getLog());
5151
}

build-info-extractor/src/testFixtures/java/org/jfrog/build/IntegrationTestsBase.java

+17-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public static Log getLog() {
5959
return log;
6060
}
6161

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

73-
platformUrl = readParam(props, "url", "http://127.0.0.1:8081");
77+
platformUrl = readParam(props, "url", "http://127.0.0.1:" + testPort);
7478
if (!platformUrl.endsWith("/")) {
7579
platformUrl += "/";
7680
}
@@ -92,6 +96,16 @@ public void init() throws IOException {
9296
}
9397
}
9498

99+
@BeforeClass
100+
public void init() throws IOException {
101+
init(false);
102+
}
103+
104+
@BeforeClass
105+
public void accessInit() throws IOException {
106+
init(true);
107+
}
108+
95109
@AfterClass
96110
protected void terminate() throws IOException {
97111
// Delete the virtual first.

0 commit comments

Comments
 (0)