Skip to content

Commit dd8dd11

Browse files
committed
BI-162 - Added vcsUrl to capture the version control URL (in addition to the existing vcsRevision)
1 parent eb88bd0 commit dd8dd11

File tree

10 files changed

+106
-37
lines changed

10 files changed

+106
-37
lines changed

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

+21-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public class Build extends BaseBuildBean {
5151
private String parentName;
5252
private String parentNumber;
5353
private String vcsRevision;
54+
private String vcsUrl;
55+
5456
@Deprecated
5557
private String parentBuildId;
5658

@@ -177,6 +179,24 @@ public void setVcsRevision(String vcsRevision) {
177179
this.vcsRevision = vcsRevision;
178180
}
179181

182+
/**
183+
* Returns the vcs URL (format is vcs specific)
184+
*
185+
* @return The vcs URL
186+
*/
187+
public String getVcsUrl() {
188+
return vcsUrl;
189+
}
190+
191+
/**
192+
* Sets the vcs URL (format is vcs specific)
193+
*
194+
* @param vcsUrl The vcs URL
195+
*/
196+
public void setVcsUrl(String vcsUrl) {
197+
this.vcsUrl = vcsUrl;
198+
}
199+
180200
/**
181201
* Returns the type of the build
182202
*
@@ -351,7 +371,7 @@ public String getParentBuildId() {
351371
*
352372
* @param parentBuildId Build parent build ID
353373
* @deprecated Use {@link org.jfrog.build.api.Build#setParentName(String)} and {@link Build#setParentNumber(String)}
354-
* instead.
374+
* instead.
355375
*/
356376
@Deprecated
357377
public void setParentBuildId(String parentBuildId) {

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

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public interface BuildInfoFields {
2626
String BUILD_PARENT_NAME = "build.parentName";
2727
String BUILD_PARENT_NUMBER = "build.parentNumber";
2828
String VCS_REVISION = "vcs.revision";
29+
String VCS_URL = "vcs.url";
2930
String PRINCIPAL = "principal";
3031
String BUILD_URL = "buildUrl";
3132
String BUILD_AGENT_NAME = "buildAgent.name";

build-info-api/src/main/java/org/jfrog/build/api/builder/BuildInfoBuilder.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@
1818

1919
import com.google.common.collect.Lists;
2020
import org.apache.commons.lang.StringUtils;
21-
import org.jfrog.build.api.Agent;
22-
import org.jfrog.build.api.BlackDuckProperties;
23-
import org.jfrog.build.api.Build;
24-
import org.jfrog.build.api.BuildAgent;
25-
import org.jfrog.build.api.BuildRetention;
26-
import org.jfrog.build.api.BuildType;
27-
import org.jfrog.build.api.Governance;
28-
import org.jfrog.build.api.Issues;
29-
import org.jfrog.build.api.LicenseControl;
30-
import org.jfrog.build.api.Module;
21+
import org.jfrog.build.api.*;
3122
import org.jfrog.build.api.release.PromotionStatus;
3223

3324
import java.text.SimpleDateFormat;
@@ -56,6 +47,7 @@ public class BuildInfoBuilder {
5647
private String parentName;
5748
private String parentNumber;
5849
private String vcsRevision;
50+
private String vcsUrl;
5951
private List<Module> modules;
6052
private List<PromotionStatus> statuses;
6153
private Properties properties;
@@ -104,6 +96,7 @@ public Build build() {
10496
build.setStatuses(statuses);
10597
build.setProperties(properties);
10698
build.setVcsRevision(vcsRevision);
99+
build.setVcsUrl(vcsUrl);
107100
build.setLicenseControl(licenseControl);
108101
build.setBuildRetention(buildRetention);
109102
build.setIssues(issues);
@@ -278,6 +271,17 @@ public BuildInfoBuilder vcsRevision(String vcsRevision) {
278271
return this;
279272
}
280273

274+
/**
275+
* Sets the vcs revision (format is vcs specific)
276+
*
277+
* @param vcsUrl The vcs revision
278+
* @return Builder instance
279+
*/
280+
public BuildInfoBuilder vcsUrl(String vcsUrl) {
281+
this.vcsUrl = vcsUrl;
282+
return this;
283+
}
284+
281285
/**
282286
* Sets the modules of the build
283287
*

build-info-api/src/main/java/org/jfrog/build/api/builder/BuildInfoMavenBuilder.java

+13
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class BuildInfoMavenBuilder {
5050
private String parentName;
5151
private String parentNumber;
5252
private String vcsRevision;
53+
private String vcsUrl;
5354
private List<Module> modules;
5455
private List<PromotionStatus> statuses;
5556
private Properties properties;
@@ -98,6 +99,7 @@ public Build build() {
9899
build.setStatuses(statuses);
99100
build.setProperties(properties);
100101
build.setVcsRevision(vcsRevision);
102+
build.setVcsUrl(vcsUrl);
101103
build.setLicenseControl(licenseControl);
102104
build.setBuildRetention(buildRetention);
103105
build.setIssues(issues);
@@ -272,6 +274,17 @@ public BuildInfoMavenBuilder vcsRevision(String vcsRevision) {
272274
return this;
273275
}
274276

277+
/**
278+
* Sets the vcs URL (format is vcs specific)
279+
*
280+
* @param vcsUrl The vcs revision
281+
* @return Builder instance
282+
*/
283+
public BuildInfoMavenBuilder vcsUrl(String vcsUrl) {
284+
this.vcsUrl = vcsUrl;
285+
return this;
286+
}
287+
275288
/**
276289
* Sets the modules of the build
277290
*

build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java

+25-15
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public Map<String, String> getAllRootConfig() {
9393
}
9494

9595
public void persistToPropertiesFile() {
96-
if ( StringUtils.isEmpty( getPropertiesFile())) {
96+
if (StringUtils.isEmpty(getPropertiesFile())) {
9797
return;
9898
}
9999
Predicate<String> nonNullPredicate = new Predicate<String>() {
@@ -278,28 +278,28 @@ public String getSnapshotRepoKey() {
278278
return getStringValue(SNAPSHOT_REPO_KEY);
279279
}
280280

281-
public void setAggregateArtifacts ( String path ) {
282-
setStringValue( AGGREGATE_ARTIFACTS, path);
281+
public void setAggregateArtifacts(String path) {
282+
setStringValue(AGGREGATE_ARTIFACTS, path);
283283
}
284284

285-
public String getAggregateArtifacts () {
286-
return getStringValue( AGGREGATE_ARTIFACTS );
285+
public String getAggregateArtifacts() {
286+
return getStringValue(AGGREGATE_ARTIFACTS);
287287
}
288288

289-
public void setCopyAggregatedArtifacts ( Boolean enabled ) {
290-
setBooleanValue( COPY_AGGREGATED_ARTIFACTS, enabled );
289+
public void setCopyAggregatedArtifacts(Boolean enabled) {
290+
setBooleanValue(COPY_AGGREGATED_ARTIFACTS, enabled);
291291
}
292292

293-
public void setPublishAggregatedArtifacts ( Boolean enabled ) {
294-
setBooleanValue( PUBLISH_AGGREGATED_ARTIFACTS, enabled );
293+
public void setPublishAggregatedArtifacts(Boolean enabled) {
294+
setBooleanValue(PUBLISH_AGGREGATED_ARTIFACTS, enabled);
295295
}
296296

297-
public Boolean isCopyAggregatedArtifacts () {
298-
return getBooleanValue( COPY_AGGREGATED_ARTIFACTS, false );
297+
public Boolean isCopyAggregatedArtifacts() {
298+
return getBooleanValue(COPY_AGGREGATED_ARTIFACTS, false);
299299
}
300300

301-
public Boolean isPublishAggregatedArtifacts () {
302-
return getBooleanValue( PUBLISH_AGGREGATED_ARTIFACTS, false );
301+
public Boolean isPublishAggregatedArtifacts() {
302+
return getBooleanValue(PUBLISH_AGGREGATED_ARTIFACTS, false);
303303
}
304304

305305
public void setPublishArtifacts(Boolean enabled) {
@@ -331,7 +331,7 @@ public String getIncludePatterns() {
331331
}
332332

333333
public boolean isFilterExcludedArtifactsFromBuild() {
334-
return getBooleanValue(FILTER_EXCLUDED_ARTIFACTS_FROM_BUILD,false);
334+
return getBooleanValue(FILTER_EXCLUDED_ARTIFACTS_FROM_BUILD, false);
335335
}
336336

337337
public void setExcludePatterns(String patterns) {
@@ -440,7 +440,9 @@ public void setUrl(String url) {
440440
}
441441

442442
public String urlWithMatrixParams(String rootUrl) {
443-
if ( rootUrl == null ) { return null; }
443+
if (rootUrl == null) {
444+
return null;
445+
}
444446
rootUrl = StringUtils.stripEnd(rootUrl, "/;");
445447
Map<String, String> matrixParams = getMatrixParams();
446448
if (matrixParams.isEmpty()) {
@@ -842,6 +844,14 @@ public String getVcsRevision() {
842844
return getStringValue(VCS_REVISION);
843845
}
844846

847+
public void setVcsUrl(String vcsUrl) {
848+
setStringValue(VCS_URL, vcsUrl);
849+
}
850+
851+
public String getVcsUrl() {
852+
return getStringValue(VCS_URL);
853+
}
854+
845855
public void setAgentName(String agentName) {
846856
setStringValue(AGENT_NAME, agentName);
847857
}

build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/extractor/GradleBuildInfoExtractor.java

+5
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ public Build extract(Project rootProject) {
141141
bib.vcsRevision(vcsRevision);
142142
}
143143

144+
String vcsUrl = clientConf.info.getVcsUrl();
145+
if (StringUtils.isNotBlank(vcsUrl)) {
146+
bib.vcsUrl(vcsUrl);
147+
}
148+
144149
LicenseControl licenseControl = new LicenseControl(clientConf.info.licenseControl.isRunChecks());
145150
String notificationRecipients = clientConf.info.licenseControl.getViolationRecipients();
146151
if (StringUtils.isNotBlank(notificationRecipients)) {

build-info-extractor-ivy/src/main/java/org/jfrog/build/extractor/listener/ArtifactoryBuildListener.java

+8
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ private void doDeploy(BuildEvent event) {
233233
if (StringUtils.isNotBlank(buildUrl)) {
234234
builder.url(buildUrl);
235235
}
236+
String vcsRevision = clientConf.info.getVcsRevision();
237+
if (StringUtils.isNotBlank(vcsRevision)) {
238+
builder.vcsRevision(vcsRevision);
239+
}
240+
String vcsUrl = clientConf.info.getVcsUrl();
241+
if (StringUtils.isNotBlank(vcsUrl)) {
242+
builder.vcsUrl(vcsUrl);
243+
}
236244
String principal = clientConf.info.getPrincipal();
237245
if (StringUtils.isNotBlank(principal)) {
238246
builder.principal(principal);

build-info-extractor-ivy/src/main/java/org/jfrog/build/extractor/trigger/ArtifactoryBuildInfoTrigger.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private void collectDependencyInformation(IvyEvent event) {
143143
private void collectModuleInformation(IvyEvent event) {
144144
ArtifactoryClientConfiguration.PublisherHandler publisher = ctx.getClientConf().publisher;
145145
IncludeExcludePatterns patterns = new IncludeExcludePatterns(
146-
publisher.getIncludePatterns(),publisher.getExcludePatterns());
146+
publisher.getIncludePatterns(), publisher.getExcludePatterns());
147147
boolean excludeArtifactsFromBuild = publisher.isFilterExcludedArtifactsFromBuild();
148148
Project project = (Project) IvyContext.peekInContextStack(IvyTask.ANT_PROJECT_CONTEXT_KEY);
149149

@@ -180,7 +180,7 @@ private void collectModuleInformation(IvyEvent event) {
180180
project.log("[buildinfo:collect] Collecting artifact " + name + " for module " + moduleName +
181181
" using file " + file, Project.MSG_INFO);
182182

183-
if (isArtifactExist(module.getArtifacts(), name)||isArtifactExist(module.getExcludedArtifacts(), name)) {
183+
if (isArtifactExist(module.getArtifacts(), name) || isArtifactExist(module.getExcludedArtifacts(), name)) {
184184
return;
185185
}
186186
ArtifactBuilder artifactBuilder = new ArtifactBuilder(name);
@@ -192,9 +192,9 @@ private void collectModuleInformation(IvyEvent event) {
192192
String sha1 = checksums.get(SHA1);
193193
artifactBuilder.md5(md5).sha1(sha1);
194194
Artifact artifact = artifactBuilder.build();
195-
if(excludeArtifactsFromBuild && PatternMatcher.pathConflicts(fullPath,patterns)){
195+
if (excludeArtifactsFromBuild && PatternMatcher.pathConflicts(fullPath, patterns)) {
196196
module.getExcludedArtifacts().add(artifact);
197-
}else{
197+
} else {
198198
module.getArtifacts().add(artifact);
199199
}
200200
@SuppressWarnings("unchecked") DeployDetails deployDetails =
@@ -229,6 +229,9 @@ private DeployDetails buildDeployDetails(File artifactFile, Artifact artifact,
229229
if (StringUtils.isNotBlank(clientConf.info.getVcsRevision())) {
230230
builder.addProperty(BuildInfoFields.VCS_REVISION, clientConf.info.getVcsRevision());
231231
}
232+
if (StringUtils.isNotBlank(clientConf.info.getVcsUrl())) {
233+
builder.addProperty(BuildInfoFields.VCS_URL, clientConf.info.getVcsUrl());
234+
}
232235
if (StringUtils.isNotBlank(clientConf.info.getBuildName())) {
233236
builder.addProperty(BuildInfoFields.BUILD_NAME, clientConf.info.getBuildName());
234237
}

build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/BuildInfoModelPropertyResolver.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.jfrog.build.extractor.maven;
22

3-
import static org.jfrog.build.api.BuildInfoFields.*;
43
import com.google.common.io.Closeables;
54
import org.apache.commons.lang.StringUtils;
65
import org.apache.maven.Maven;
@@ -23,6 +22,8 @@
2322
import java.util.Properties;
2423
import java.util.Set;
2524

25+
import static org.jfrog.build.api.BuildInfoFields.*;
26+
2627

2728
/**
2829
* @author Noam Y. Tenne
@@ -49,6 +50,10 @@ public BuildInfoMavenBuilder resolveProperties(ExecutionEvent event, Artifactory
4950
if (StringUtils.isNotBlank(vcsRevision)) {
5051
builder.vcsRevision(vcsRevision);
5152
}
53+
String vcsUrl = clientConf.info.getVcsUrl();
54+
if (StringUtils.isNotBlank(vcsUrl)) {
55+
builder.vcsUrl(vcsUrl);
56+
}
5257
BuildAgent buildAgent = new BuildAgent("Maven", getMavenVersion());
5358
builder.buildAgent(buildAgent);
5459

@@ -140,7 +145,7 @@ private void attachStagingIfNeeded(ArtifactoryClientConfiguration clientConf, Bu
140145
}
141146

142147
private BuildInfoMavenBuilder resolveCoreProperties(ExecutionEvent event,
143-
ArtifactoryClientConfiguration clientConf) {
148+
ArtifactoryClientConfiguration clientConf) {
144149
String buildName = clientConf.info.getBuildName();
145150
if (StringUtils.isBlank(buildName)) {
146151
buildName = event.getSession().getTopLevelProject().getName();
@@ -169,14 +174,14 @@ private BuildInfoMavenBuilder resolveCoreProperties(ExecutionEvent event,
169174
private String getMavenVersion() {
170175
Properties mavenVersionProperties = new Properties();
171176
InputStream inputStream = BuildInfoRecorder.class.getClassLoader().
172-
getResourceAsStream( "org/apache/maven/messages/build.properties" );
177+
getResourceAsStream("org/apache/maven/messages/build.properties");
173178
if (inputStream == null) {
174179
inputStream = Maven.class.getClassLoader().
175-
getResourceAsStream( "META-INF/maven/org.apache.maven/maven-core/pom.properties" );
180+
getResourceAsStream("META-INF/maven/org.apache.maven/maven-core/pom.properties");
176181
}
177182
if (inputStream == null) {
178183
throw new RuntimeException("Could not extract Maven version: unable to find resources " +
179-
"'org/apache/maven/messages/build.properties' or 'META-INF/maven/org.apache.maven/maven-core/pom.properties'");
184+
"'org/apache/maven/messages/build.properties' or 'META-INF/maven/org.apache.maven/maven-core/pom.properties'");
180185
}
181186
try {
182187
mavenVersionProperties.load(inputStream);
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sun Oct 06 22:28:40 CEST 2013
1+
#Tue Mar 18 16:58:19 IST 2014
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
6+
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip

0 commit comments

Comments
 (0)