-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update VSTS PR Jenkins build status back to VSTS #175
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d11525f
Merge remote-tracking branch 'refs/remotes/jenkinsci/master'
smile21prc 8d33bd4
Merge branch 'master' of git://github.com/jenkinsci/tfs-plugin
smile21prc bb6d9c9
Merge remote-tracking branch 'upstream/master'
smile21prc e599ec7
Merge remote-tracking branch 'upstream/master'
smile21prc b92d2a9
Update VSTS PR Jenkins build status back to VSTS
smile21prc abf475b
More changes.
smile21prc 45f897e
Remove redudant API
smile21prc cc9adb2
Add support of reporting build status of multi-jobs triggered by one PR
smile21prc 6628c90
Add support of showing customized run config in VSTS PR Status UI.
smile21prc 4d30307
Add a few null check.
smile21prc eb8fad7
Remove unnecessary status update.
smile21prc 6e33741
Fixed status display typo
smile21prc a047e8d
Add jelly support
smile21prc 614d260
Add a seperate checkbox for PR trigger, and fully enable its status u…
smile21prc 7ee55be
Remove redundant entry in pom
smile21prc e617e3b
Address review comments.
smile21prc 032b538
Address review comments.
smile21prc 8de1f7a
Pass additional params to Jenkins build for PR job auto-gen
smile21prc 868c8ba
Renaming to vstsBranchOrCommit
smile21prc 530bb4b
Add constructor to allow creating a job trigger with job context param.
smile21prc d66e61b
Added support of branch-specific triggering for both PR and code push
smile21prc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
tfs/src/main/java/hudson/plugins/tfs/SafeParametersAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package hudson.plugins.tfs; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.EnvironmentContributor; | ||
import hudson.model.ParameterValue; | ||
import hudson.model.ParametersAction; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Extension class of ParametersAction to pass in parameters as safe parameters.. | ||
*/ | ||
@Restricted(NoExternalUse.class) | ||
public class SafeParametersAction extends ParametersAction { | ||
|
||
private List<ParameterValue> parameters; | ||
|
||
public SafeParametersAction(final List<ParameterValue> parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
public SafeParametersAction(final ParameterValue... parameters) { | ||
this(Arrays.asList(parameters)); | ||
} | ||
|
||
@Override | ||
public List<ParameterValue> getParameters() { | ||
return Collections.unmodifiableList(parameters); | ||
} | ||
|
||
@Override | ||
public ParameterValue getParameter(final String name) { | ||
for (ParameterValue parameter : parameters) { | ||
if (parameter != null && parameter.getName().equals(name)) { | ||
return parameter; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Environment contributor for SafeParametersAction. | ||
*/ | ||
@Extension | ||
public static final class SafeParametersActionEnvironmentContributor extends EnvironmentContributor { | ||
|
||
@Override | ||
public void buildEnvironmentFor(final Run r, final EnvVars envs, final TaskListener listener) throws IOException, InterruptedException { | ||
SafeParametersAction action = r.getAction(SafeParametersAction.class); | ||
if (action != null) { | ||
for (ParameterValue p : action.getParameters()) { | ||
envs.putIfNotNull(p.getName(), String.valueOf(p.getValue())); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tfs/src/main/java/hudson/plugins/tfs/TeamPRPushTrigger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package hudson.plugins.tfs; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Job; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
|
||
/** | ||
* Triggers a build when we receive a TFS/Team Services Git code push event in a TFS pull request. | ||
*/ | ||
public class TeamPRPushTrigger extends TeamPushTrigger { | ||
|
||
private String targetBranches; | ||
|
||
@DataBoundConstructor | ||
public TeamPRPushTrigger() { | ||
} | ||
|
||
public TeamPRPushTrigger(final Job<?, ?> job, final String targetBranches, final String jobContext) { | ||
this.job = job; | ||
this.targetBranches = targetBranches; | ||
|
||
setJobContext(jobContext); | ||
} | ||
|
||
public String getTargetBranches() { | ||
return targetBranches; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setTargetBranches(final String targetBranches) { | ||
this.targetBranches = targetBranches; | ||
} | ||
|
||
/** | ||
* This class extends trigger descriptor class from TeamPushTrigger, creating a separate check box for TeamPRPushTrigger. | ||
*/ | ||
@Extension | ||
public static class DescriptorImpl extends TeamPushTrigger.DescriptorImpl { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Build when a change is pushed to a TFS pull request"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nop, I don't see one in its member list, if a job isn't a ParameterizedJob: