本文整理汇总了Java中hudson.plugins.git.util.BuildData.getLastBuiltRevision方法的典型用法代码示例。如果您正苦于以下问题:Java BuildData.getLastBuiltRevision方法的具体用法?Java BuildData.getLastBuiltRevision怎么用?Java BuildData.getLastBuiltRevision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.plugins.git.util.BuildData
的用法示例。
在下文中一共展示了BuildData.getLastBuiltRevision方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCommitRepoMap
import hudson.plugins.git.util.BuildData; //导入方法依赖的package包/类
public Map<String, URIish> getCommitRepoMap() throws Exception {
List<RemoteConfig> repoList = this.gitScm.getRepositories();
if (repoList.size() != 1) {
throw new Exception("None or multiple repos");
}
HashMap<String, URIish> commitRepoMap = new HashMap<String, URIish>();
BuildData buildData = build.getAction(BuildData.class);
if (buildData == null || buildData.getLastBuiltRevision() == null) {
logger.warning("Build data could not be found");
} else {
commitRepoMap.put(buildData.getLastBuiltRevision().getSha1String(), repoList.get(0).getURIs().get(0));
}
return commitRepoMap;
}
示例2: getCandidateRevisions
import hudson.plugins.git.util.BuildData; //导入方法依赖的package包/类
/**
* Get failing build revision if this is a deflake build, otherwise use the default build chooser
*/
@Override
public Collection<Revision> getCandidateRevisions(boolean isPollCall, String singleBranch,
GitClient git,
TaskListener listener, BuildData buildData,
BuildChooserContext context)
throws GitException, IOException, InterruptedException {
AbstractBuild build = context.actOnBuild(new GetBuild());
// Not sure why it cannot be inferred and we have to put cast here
DeflakeCause cause = (DeflakeCause) build.getCause(DeflakeCause.class);
if (cause != null) {
BuildData gitBuildData = gitSCM.getBuildData(cause.getUpstreamRun(), true);
Revision revision = gitBuildData.getLastBuiltRevision();
if (revision != null) {
return Collections.singletonList(revision);
}
}
// If it is not a deflake run, then use the default git checkout strategy
defaultBuildChooser.gitSCM = this.gitSCM;
return defaultBuildChooser
.getCandidateRevisions(isPollCall, singleBranch, git, listener, buildData, context);
}
示例3: SingleTestFlakyStatsWithRevision
import hudson.plugins.git.util.BuildData; //导入方法依赖的package包/类
/**
* Construct a SingleTestFlakyStatsWithRevision object with {@link SingleTestFlakyStats} and
* build information.
*
* @param stats Embedded {@link SingleTestFlakyStats} object
* @param build The {@link hudson.model.AbstractBuild} object to get SCM information from.
*/
public SingleTestFlakyStatsWithRevision(SingleTestFlakyStats stats, AbstractBuild build) {
this.stats = stats;
revision = Integer.toString(build.getNumber());
SCM scm = build.getProject().getScm();
if (scm != null && scm instanceof GitSCM) {
GitSCM gitSCM = (GitSCM) scm;
BuildData buildData = gitSCM.getBuildData(build);
if (buildData != null) {
Revision gitRevision = buildData.getLastBuiltRevision();
if (gitRevision != null) {
revision = gitRevision.getSha1String();
}
}
}
}
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:24,代码来源:HistoryAggregatedFlakyTestResultAction.java
示例4: getBuildRevision
import hudson.plugins.git.util.BuildData; //导入方法依赖的package包/类
private static String getBuildRevision(Run<?, ?> build) {
GitLabWebHookCause cause = build.getCause(GitLabWebHookCause.class);
if (cause != null) {
return cause.getData().getLastCommit();
}
BuildData action = build.getAction(BuildData.class);
if (action == null) {
throw new IllegalStateException("No (git-plugin) BuildData associated to current build");
}
Revision lastBuiltRevision = action.getLastBuiltRevision();
if (lastBuiltRevision == null) {
throw new IllegalStateException("Last build has no associated commit");
}
return action.getLastBuild(lastBuiltRevision.getSha1()).getMarked().getSha1String();
}
示例5: getGitSourceCommit
import hudson.plugins.git.util.BuildData; //导入方法依赖的package包/类
private String getGitSourceCommit() {
// depend on git plugin
for (BuildData data : getJenkinsBuild().getActions(BuildData.class)) {
Revision revision = data.getLastBuiltRevision();
if (revision != null) {
return revision.getSha1String();
}
}
return null;
}
示例6: onCompleted
import hudson.plugins.git.util.BuildData; //导入方法依赖的package包/类
public void onCompleted(AbstractBuild<?, ?> build, TaskListener listener) {
GhprcCause c = Ghprc.getCause(build);
if (c == null) {
return;
}
// remove the BuildData action that we may have added earlier to avoid
// having two of them, and because the one we added isn't correct
// @see GhprcTrigger
BuildData fakeOne = null;
for (BuildData data : build.getActions(BuildData.class)) {
if (data.getLastBuiltRevision() != null && !data.getLastBuiltRevision().getSha1String().equals(c.getCommit())) {
fakeOne = data;
break;
}
}
if (fakeOne != null) {
build.getActions().remove(fakeOne);
}
for (GhprcExtension ext : Ghprc.getJobExtensions(trigger, GhprcCommitStatus.class)) {
if (ext instanceof GhprcCommitStatus) {
try {
((GhprcCommitStatus) ext).onBuildComplete(build, listener, repo.getGitHubRepo());
} catch (GhprcCommitStatusException e) {
repo.commentOnFailure(build, listener, e);
}
}
}
GHCommitState state;
state = Ghprc.getState(build);
commentOnBuildResult(build, listener, c);
// close failed pull request automatically
if (state == GHCommitState.FAILURE && trigger.isAutoCloseFailedPullRequests()) {
closeFailedRequest(listener, c);
}
}
示例7: fromPull
import hudson.plugins.git.util.BuildData; //导入方法依赖的package包/类
public static String fromPull(BuildData buildData, Optional<String> organization) {
Set<String> remoteUrls = buildData.getRemoteUrls();
checkArgument(!remoteUrls.isEmpty(), "buildData does not contain any remote URLs");
Revision lastBuiltRevision = buildData.getLastBuiltRevision();
Collection<hudson.plugins.git.Branch> scmBranches = lastBuiltRevision.getBranches();
checkArgument(!scmBranches.isEmpty(), "buildData last revision does not contain any branches");
String firstRemoteUrl = remoteUrls.iterator().next();
Repository repository = new Repository(firstRemoteUrl);
hudson.plugins.git.Branch firstScmBranch = scmBranches.iterator().next();
Branch branch = new Branch(firstScmBranch);
return generateRemoteImageName(organization, repository, branch);
}