本文整理汇总了Java中hudson.plugins.git.util.BuildData类的典型用法代码示例。如果您正苦于以下问题:Java BuildData类的具体用法?Java BuildData怎么用?Java BuildData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildData类属于hudson.plugins.git.util包,在下文中一共展示了BuildData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: tryGetRemoteImage
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
@Override
public Optional<String> tryGetRemoteImage(PushPublisher publisher, SpoonBuild build) {
Optional<String> organization = Optional.absent();
if (publisher.isOverwriteOrganization()) {
organization = Optional.fromNullable(publisher.getOrganization());
}
PushCause cause = build.getCause(PushCause.class);
if (cause != null) {
return Optional.of(RemoteImageGenerator.fromPush(cause, organization));
}
BuildData buildData = build.getAction(BuildData.class);
if (buildData != null) {
return Optional.of(RemoteImageGenerator.fromPull(buildData, organization));
}
return Optional.absent();
}
示例5: validate
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
@Override
public void validate(PushPublisher publisher, SpoonBuild build) {
super.validate(publisher, build);
if (publisher.isOverwriteOrganization()) {
checkState(Patterns.isNullOrSingleWord(publisher.getOrganization()), REQUIRE_SINGLE_WORD_OR_NULL_SP,
"Organization", publisher.getOrganization());
}
PushCause webHookCause = build.getCause(PushCause.class);
if (webHookCause != null) {
return;
}
BuildData pullGitCause = build.getAction(BuildData.class);
if (pullGitCause != null) {
return;
}
throw new IllegalStateException("Build has not been caused by a web hook event or pulling SCM");
}
示例6: 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();
}
示例7: createProject
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
private AbstractProject<?,?> createProject(String... shas) {
AbstractBuild build = mock(AbstractBuild.class);
List<BuildData> buildDatas = new ArrayList<BuildData>();
for(String sha : shas) {
BuildData buildData = createBuildData(sha);
buildDatas.add(buildData);
}
when(build.getAction(BuildData.class)).thenReturn(buildDatas.get(0));
when(build.getActions(BuildData.class)).thenReturn(buildDatas);
AbstractProject<?, ?> project = mock(AbstractProject.class);
when(build.getProject()).thenReturn(project);
RunList list = mock(RunList.class);
when(list.iterator()).thenReturn(Arrays.asList(build).iterator());
when(project.getBuilds()).thenReturn(list);
return project;
}
示例8: createBuildData
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
private BuildData createBuildData(String sha) {
BuildData buildData = mock(BuildData.class);
Revision revision = mock(Revision.class);
when(revision.getSha1String()).thenReturn(sha);
when(buildData.getLastBuiltRevision()).thenReturn(revision);
Build gitBuild = mock(Build.class);
when(gitBuild.getMarked()).thenReturn(revision);
when(buildData.getLastBuild(any(ObjectId.class))).thenReturn(gitBuild);
when(gitBuild.getRevision()).thenReturn(revision);
when(gitBuild.isFor(sha)).thenReturn(true);
buildData.lastBuild = gitBuild;
return buildData;
}
示例9: findRelevantBuildDataImpl
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
/***
* Returns the relevant BuildDatas from the supplied list of BuildDatas.
*
* @param logger PrintStream logger
* @param buildDatas The list of BuildDatas
* @param repoName The expanded repoName
* @return The relevant BuildDatas
*/
private static Set<BuildData> findRelevantBuildDataImpl(PrintStream logger, List<BuildData> buildDatas, String repoName) {
Set<BuildData> relevantBuildData = new HashSet<>();
Set<String> revisions = new HashSet<>(); //Used to detect duplicates
for (BuildData buildData : buildDatas) {
if (buildData.lastBuild == null) continue;
Branch buildBranch = buildData.lastBuild.revision.getBranches().iterator().next();
String expandedRepository = repoName + "/"; // Assume no trailing slash in configuration
if (buildBranch.getName().startsWith(expandedRepository)) { // Check integrationBranch matches integration repository
String revisionSha = buildData.lastBuild.revision.getSha1String();
boolean isDuplicateEntry = !revisions.add(revisionSha); // Check we haven't seen this changeset before
if (isDuplicateEntry) {
LOGGER.log(Level.INFO, String.format("Revision %s has a duplicate BuildData entry. Using first.", revisionSha));
} else {
relevantBuildData.add(buildData);
}
}
}
return relevantBuildData;
}
示例10: findPreviousBuildForPullId
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
/**
* Find the previous BuildData for the given pull request number; this may return null
*/
private BuildData findPreviousBuildForPullId(StringParameterValue pullIdPv) {
// find the previous build for this particular pull requet, it may not be the last build
for (Run<?,?> r : job.getBuilds()) {
ParametersAction pa = r.getAction(ParametersAction.class);
if (pa != null) {
for (ParameterValue pv : pa.getParameters()) {
if (pv.equals(pullIdPv)) {
for (BuildData bd : r.getActions(BuildData.class)) {
return bd;
}
}
}
}
}
return null;
}
示例11: hasBeenBuilt
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
private boolean hasBeenBuilt(BuildData data, ObjectId sha1, String branch) {
try {
for(Map.Entry<String, Build> buildByBranchName : data.buildsByBranchName.entrySet()) {
String branchName = buildByBranchName.getKey();
if (branchName == null) {
branchName = "";
}
Build build = buildByBranchName.getValue();
if(branchName.equals(branch) && (build.revision.getSha1().equals(sha1) || build.marked.getSha1().equals(sha1)))
return true;
}
return false;
}
catch(Exception ex) {
return false;
}
}
示例12: 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;
}
示例13: onCompleted
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
@Override
public void onCompleted(Run<?, ?> run, @Nonnull TaskListener listener) {
GitHubPRTrigger trigger = ghPRTriggerFromRun(run);
if (isNull(trigger)) {
return;
}
GitHubPRCause cause = ghPRCauseFromRun(run);
if (nonNull(cause)) {
//remove all BuildData, because it doesn't work right with pull requests now
//TODO rework after git-client patching about BuildData usage
run.getActions().removeAll(run.getActions(BuildData.class));
}
}
示例14: checkBuildDataExistenceAfterBuild
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
@Test
public void checkBuildDataExistenceAfterBuild() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("test-job");
p.getBuildersList().add(new BuildDataBuilder());
FreeStyleBuild build = p.scheduleBuild2(0).get();
j.waitUntilNoActivity();
assertTrue(build.getActions(BuildData.class).size() > 0);
}
示例15: checkBuildDataAbsenceAfterBuild
import hudson.plugins.git.util.BuildData; //导入依赖的package包/类
@Test
public void checkBuildDataAbsenceAfterBuild() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("test-job");
p.addProperty(new GithubProjectProperty("https://github.com/KostyaSha/test-repo"));
p.addTrigger(defaultGitHubPRTrigger());
p.getBuildersList().add(new BuildDataBuilder());
GitHubPRCause cause = new GitHubPRCause("headSha", 1, true, "targetBranch", "srcBranch", "[email protected]",
"title", new URL("http://www.example.com"), "repoOwner", new HashSet<String>(),
null, false, "nice reason", "author name", "[email protected]", "open");
FreeStyleBuild build = p.scheduleBuild2(0, cause).get();
j.waitUntilNoActivity();
assertTrue(build.getActions(BuildData.class).size() == 0);
}