-
Notifications
You must be signed in to change notification settings - Fork 171
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
Update VSTS PR Jenkins build status back to VSTS #175
Conversation
Update VSTS PR Jenkins build status back to VSTS
More changes.
Remove redudant API
Add support of reporting build status of multi-jobs triggered by one PR
Add support of showing customized run config in VSTS PR Status UI.
Add a few null check.
Remove unnecessary status update.
Fixed status display typo
Add jelly support
…pdate. Add a seperate checkbox for PR trigger, and fully enable its status update.
Remove redundant entry in pom
+@mmitche @jpricketMSFT
|
Deployed the plugin to https://dotnet-vsts.westus2.cloudapp.azure.com, which worked well -- runs are correctly triggered by both PR commit and code push based on their configurations. |
List<T> triggerList = new ArrayList<>(); | ||
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) { | ||
final ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) job; | ||
for (final Trigger trigger : pJob.getTriggers().values()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there not a getTriggers on non ParameterizedJobs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -12,19 +12,22 @@ | |||
public class TeamPushCause extends SCMTriggerCause { | |||
|
|||
private final String pushedBy; | |||
private final String runConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you refactor this name to "context" just for consistency with other plugins that do similar things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, refactored it "context".
@@ -48,6 +49,9 @@ public TeamPushTrigger(final Job<?, ?> job) { | |||
this.job = job; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a future PR we should figure out whether this constructor can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will try that out in the PR to add refspec param into TeamPushTrigger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sounds good. It might be good for the trigger to inject a parameter for both the refspec and the hash. That way the same job can be used for both PRs and pushes if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
} | ||
return "Jenkins CI build"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you pull this string out into a static constant somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Refactored it as a static constant in JenkinsRunListener class:
private static final String DEFAULT_RUN_CONTEXT = "Jenkins CI build";
} | ||
|
||
private Boolean repoMatch(final GitCodePushedEventArgs gitCodePushedEventArgs, final Job job) { | ||
if (job instanceof WorkflowJob) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this work for non workflow jobs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Non-workflow jobs do repo matching check first, and calls triggerJob() only if it matches (in pullOrQueueFromEvent()), but we do need a var in triggerJob() to know the status of "this is a non-workflow job whose repo already matches).
Added a new param "final Boolean repoMatch" to triggerJob() to signal that status.
<!-- | ||
The MIT License | ||
|
||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright header should be an MS copyright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the whole file.
@@ -0,0 +1,45 @@ | |||
<!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's cloned from TeamPushTrigger. Turns out it's redudant for TeamPRPushTrigger -- it worked fine after removing it. So I've removed the whole file.
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">> | ||
<f:entry title="Job Context" field="jobContext"> | ||
<f:textbox default="Jenkins CI build" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI doesn't necessarily imply PR. Can you change this to "Jenkins PR Build"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, changed.
Address review comments.
Thanks for the review @mmitche, and I've addressed all your comments. Can you take another look at your convenient time? Thanks. |
} | ||
} | ||
} catch (final Exception e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These errors here should be sent to the logger (https://github.com/jenkinsci/tfs-plugin/pull/175/files#diff-462c46539e78a70b95caa4cf430ecbd7R39) so they are easy to find and filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
final TeamRestClient client = new TeamRestClient(collectionUri); | ||
client.addPullRequestStatus(gitCodePushedEventArgs, status); | ||
} catch (MalformedURLException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These errors here should be sent to the logger (https://github.com/jenkinsci/tfs-plugin/pull/175/files#diff-462c46539e78a70b95caa4cf430ecbd7R39) so they are easy to find and filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
} catch (MalformedURLException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These errors here should be sent to the logger (https://github.com/jenkinsci/tfs-plugin/pull/175/files#diff-462c46539e78a70b95caa4cf430ecbd7R39) so they are easy to find and filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -48,6 +49,9 @@ public TeamPushTrigger(final Job<?, ?> job) { | |||
this.job = job; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sounds good. It might be good for the trigger to inject a parameter for both the refspec and the hash. That way the same job can be used for both PRs and pushes if desired.
return new JSONObject(); | ||
} | ||
|
||
private String getRunContext(final Run run) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this code here workflow job specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. It shouldn't. I've changed it to be applied to all jobs.
Address review comments.
Pass additional params to Jenkins build for PR job auto-gen
Renaming to vstsBranchOrCommit
@mmitche, any further comments on this PR? |
Add constructor to allow creating a job trigger with job context param.
When this is merged please ensure to do a squash merge to ensure a relatively clean history. |
@mosabua , sure will. |
Hi, @jpricketMSFT, seems I don't have enough access to add you as the reviewer of this PR. There are a bunch of changes after your previous sign-off. If you've got any additional comments, please feel free to let me know. Thanks. I've deployed it to https://dotnet-vsts.westus2.cloudapp.azure.com/job/DevDiv_dotnet-linker, and verified both PR and Push trigger & VSTS status update worked well -- https://dotnet-vsts.westus2.cloudapp.azure.com/job/DevDiv_dotnet-linker/job/TestJobs/. |
Added support of branch-specific triggering for both PR and code push
@mmitche, added support on branch-specific triggering. PR merge jobs now are only triggered when PR happens in the branch list of PR trigger UI: While code push jobs are triggered when code push happens in a branch matching one of its Git branches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any major problems. This is a large PR, so we will do extra regression testing before releasing these changes to make sure that the other plugin features are not affected.
Thanks @jpricketMSFT . |
Update VSTS PR Jenkins build status back to VSTS.
Re-target the PR smile21prc#2 to official plug-in branch.