Skip to content

Commit

Permalink
Do not process repo URI string when "Jenkins Queue Job" task invokes …
Browse files Browse the repository at this point in the history
…a Jenkins job from TFS Release Management
  • Loading branch information
davidstaheli committed Dec 7, 2016
1 parent 7eabe15 commit 465021e
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions tfs/src/main/java/hudson/plugins/tfs/model/BuildCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,27 @@ static void contributeTeamBuildParameterActions(final Map<String, String> teamBu
final boolean isTeamGit = "TfGit".equalsIgnoreCase(provider)
|| "TfsGit".equalsIgnoreCase(provider);
if (isTeamGit) {
final String collectionUriString = teamBuildParameters.get(SYSTEM_TEAM_FOUNDATION_COLLECTION_URI);
final URI collectionUri = URI.create(collectionUriString);
// "Build.Repository.Uri" is null/whitespace/empty when the 'Jenkins Queue Job' task runs in TFS Release Management.
// In this case, do not reference a CommitParameterAction in the actions reported as unsupported.
final String repoUriString = teamBuildParameters.get(BUILD_REPOSITORY_URI);
final URI repoUri = URI.create(repoUriString);
final String projectId = teamBuildParameters.get(SYSTEM_TEAM_PROJECT);
final String repoId = teamBuildParameters.get(BUILD_REPOSITORY_NAME);
final String commit = teamBuildParameters.get(BUILD_SOURCE_VERSION);
final String pushedBy = teamBuildParameters.get(BUILD_REQUESTED_FOR);
final GitCodePushedEventArgs args = new GitCodePushedEventArgs();
args.collectionUri = collectionUri;
args.repoUri = repoUri;
args.projectId = projectId;
args.repoId = repoId;
args.commit = commit;
args.pushedBy = pushedBy;
final CommitParameterAction action = new CommitParameterAction(args);
actions.add(action);
if (repoUriString != null && !repoUriString.trim().isEmpty()) {
final URI repoUri = URI.create(repoUriString);
final String collectionUriString = teamBuildParameters.get(SYSTEM_TEAM_FOUNDATION_COLLECTION_URI);
final URI collectionUri = URI.create(collectionUriString);
final String projectId = teamBuildParameters.get(SYSTEM_TEAM_PROJECT);
final String repoId = teamBuildParameters.get(BUILD_REPOSITORY_NAME);
final String commit = teamBuildParameters.get(BUILD_SOURCE_VERSION);
final String pushedBy = teamBuildParameters.get(BUILD_REQUESTED_FOR);
final GitCodePushedEventArgs args = new GitCodePushedEventArgs();
args.collectionUri = collectionUri;
args.repoUri = repoUri;
args.projectId = projectId;
args.repoId = repoId;
args.commit = commit;
args.pushedBy = pushedBy;
final CommitParameterAction action = new CommitParameterAction(args);
actions.add(action);
}

UnsupportedIntegrationAction.addToBuild(actions, "Posting build status is not supported for builds triggered by the 'Jenkins Queue Job' task.");
}
Expand Down

0 comments on commit 465021e

Please sign in to comment.