本文整理汇总了Java中com.coravy.hudson.plugins.github.GithubProjectProperty类的典型用法代码示例。如果您正苦于以下问题:Java GithubProjectProperty类的具体用法?Java GithubProjectProperty怎么用?Java GithubProjectProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GithubProjectProperty类属于com.coravy.hudson.plugins.github包,在下文中一共展示了GithubProjectProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRepoFullName
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
public GitHubRepositoryName getRepoFullName(Job<?, ?> job) {
if (isNull(repoName)) {
checkNotNull(job, "job object is null, race condition?");
GithubProjectProperty ghpp = job.getProperty(GithubProjectProperty.class);
checkNotNull(ghpp, "GitHub project property is not defined. Can't setup GitHub trigger for job %s",
job.getName());
checkNotNull(ghpp.getProjectUrl(), "A GitHub project url is required");
GitHubRepositoryName repo = GitHubRepositoryName.create(ghpp.getProjectUrl().baseUrl());
checkNotNull(repo, "Invalid GitHub project url: %s", ghpp.getProjectUrl().baseUrl());
setRepoName(repo);
}
return repoName;
}
示例2: dontFailOnBadJob
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Test
public void dontFailOnBadJob() throws IOException, ANTLRException {
String goodRepo = "https://github.com/KostyaSha-auto/test-repo";
final FreeStyleProject job1 = jenkins.createProject(FreeStyleProject.class, "bad job");
job1.addProperty(new GithubProjectProperty("http://bad.url/deep/bad/path/"));
job1.addTrigger(new GitHubPRTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList()));
Set<Job> jobs = getPRTriggerJobs(goodRepo);
MatcherAssert.assertThat(jobs, hasSize(0));
final FreeStyleProject job2 = jenkins.createProject(FreeStyleProject.class, "good job");
job2.addProperty(new GithubProjectProperty(goodRepo));
job2.addTrigger(new GitHubPRTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList()));
jobs = getPRTriggerJobs("KostyaSha-auto/test-repo");
MatcherAssert.assertThat(jobs, hasSize(1));
MatcherAssert.assertThat(jobs, hasItems(job2));
}
示例3: createForCommonExpectations
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
/**
* Requires @PrepareForTest({GithubProjectProperty.class, GithubUrl.class}) in class usig it.
*
* @param filePath job's root directory.
* @param job mock job.
* @param trigger mock trigger that is expected to be returned via job.getTrigger(GitHubPRTrigger.class).
*/
public static void createForCommonExpectations(String filePath,
Job job,
GitHubPRTrigger trigger) {
GithubUrl githubUrl = PowerMockito.mock(GithubUrl.class);
when(githubUrl.toString()).thenReturn("http://blaur");
GithubProjectProperty projectProperty = PowerMockito.mock(GithubProjectProperty.class);
File file = new File(filePath);
when(job.getRootDir()).thenReturn(file);
when(job.getFullName()).thenReturn("jobFullName");
PowerMockito.mockStatic(JobHelper.class);
given(ghPRTriggerFromJob(job))
.willReturn(trigger);
when(trigger.getJob()).thenReturn(job);
when(trigger.getRepoFullName(job)).thenReturn(mock(GitHubRepositoryName.class));
when(job.getProperty(GithubProjectProperty.class)).thenReturn(projectProperty);
when(projectProperty.getProjectUrl()).thenReturn(githubUrl);
}
示例4: dontFailOnBadJob
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Test
public void dontFailOnBadJob() throws IOException, ANTLRException {
String goodRepo = "https://github.com/KostyaSha-auto/test-repo";
final FreeStyleProject job1 = jRule.createProject(FreeStyleProject.class, "bad job");
job1.addProperty(new GithubProjectProperty("http://bad.url/deep/bad/path/"));
job1.addTrigger(new GitHubBranchTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList()));
Set<Job> jobs = getBranchTriggerJobs(goodRepo);
assertThat(jobs, hasSize(0));
final FreeStyleProject job2 = jRule.createProject(FreeStyleProject.class, "good job");
job2.addProperty(new GithubProjectProperty(goodRepo));
job2.addTrigger(new GitHubBranchTrigger("", GitHubPRTriggerMode.HEAVY_HOOKS_CRON, emptyList()));
jobs = getBranchTriggerJobs("KostyaSha-auto/test-repo");
assertThat(jobs, hasSize(1));
assertThat(jobs, hasItems(job2));
}
示例5: start
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Override
public void start(AbstractProject<?, ?> project, boolean newInstance) {
// We should always start the trigger, and handle cases where we don't run in the run function.
super.start(project, newInstance);
this._project = project;
this.project = project.getFullName();
if (project.isDisabled()) {
logger.log(Level.INFO, "Project is disabled, not starting trigger for job " + this.project);
return;
}
if (project.getProperty(GithubProjectProperty.class) == null) {
logger.log(Level.INFO, "GitHub project property is missing the URL, cannot start ghprc trigger for job " + this.project);
return;
}
try {
helper = createGhprc(project);
} catch (IllegalStateException ex) {
logger.log(Level.SEVERE, "Can't start ghprc trigger", ex);
return;
}
logger.log(Level.INFO, "Starting the ghprc trigger for the {0} job; newInstance is {1}",
new String[] { this.project, String.valueOf(newInstance) });
helper.init();
}
示例6: Ghprc
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
public Ghprc(AbstractProject<?, ?> project, GhprcTrigger trigger, ConcurrentMap<Integer, GhprcPullRequest> pulls) {
this.project = project;
final GithubProjectProperty ghpp = project.getProperty(GithubProjectProperty.class);
if (ghpp == null || ghpp.getProjectUrl() == null) {
throw new IllegalStateException("A GitHub project url is required.");
}
String baseUrl = ghpp.getProjectUrl().baseUrl();
Matcher m = githubUserRepoPattern.matcher(baseUrl);
if (!m.matches()) {
throw new IllegalStateException(String.format("Invalid GitHub project url: %s", baseUrl));
}
final String user = m.group(2);
final String repo = m.group(3);
this.trigger = trigger;
this.repository = new GhprcRepository(user, repo, this, pulls);
this.builds = new GhprcBuilds(trigger, repository);
}
示例7: shouldBuildTriggersOnUpdatingNewCommitsPR
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Test
public void shouldBuildTriggersOnUpdatingNewCommitsPR() throws Exception {
// GIVEN
FreeStyleProject project = jenkinsRule.createFreeStyleProject("PRJ");
GhprcTrigger trigger = GhprcTestUtil.getTrigger(null);
given(commitPointer.getSha()).willReturn("sha").willReturn("sha").willReturn("newOne").willReturn("newOne");
given(ghPullRequest.getComments()).willReturn(Lists.<GHIssueComment> newArrayList());
GhprcTestUtil.setupGhprcTriggerDescriptor(null);
project.addProperty(new GithubProjectProperty("https://github.com/user/dropwizard"));
given(ghPullRequest.getNumber()).willReturn(2).willReturn(2).willReturn(3).willReturn(3);
Ghprc ghprc = spy(trigger.createGhprc(project));
doReturn(ghprcGitHub).when(ghprc).getGitHub();
trigger.start(project, true);
trigger.setHelper(ghprc);
ghprc.getRepository().setHelper(ghprc);
project.addTrigger(trigger);
GitSCM scm = GhprcTestUtil.provideGitSCM();
project.setScm(scm);
GhprcTestUtil.triggerRunAndWait(10, trigger, project);
assertThat(project.getBuilds().toArray().length).isEqualTo(2);
}
示例8: start
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Override
public void start(AbstractProject<?, ?> project, boolean newInstance) {
if (project.getProperty(GithubProjectProperty.class) == null) {
logger.log(Level.INFO, "GitHub project not set up, cannot start trigger for job {0}", project.getName());
return;
}
try{
ml = Ghprb.getBuilder()
.setProject(project)
.setTrigger(this)
.setPulls(DESCRIPTOR.getPullRequests(project.getFullName()))
.build();
}catch(IllegalStateException ex){
logger.log(Level.SEVERE, "Can't start trigger", ex);
return;
}
super.start(project, newInstance);
}
示例9: setProject
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
public Builder setProject(AbstractProject<?, ?> project) {
if(gml == null) return this;
gml.project = project;
GithubProjectProperty ghpp = project.getProperty(GithubProjectProperty.class);
if(ghpp == null || ghpp.getProjectUrl() == null) {
logger.log(Level.WARNING, "A github project url is required.");
gml = null;
return this;
}
String baseUrl = ghpp.getProjectUrl().baseUrl();
Matcher m = githubUserRepoPattern.matcher(baseUrl);
if(!m.matches()) {
logger.log(Level.WARNING, "Invalid github project url: {0}", baseUrl);
gml = null;
return this;
}
gml.githubServer = m.group(1);
user = m.group(2);
repo = m.group(3);
return this;
}
示例10: resolveContext
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
/**
* Determines the commit status "context" to use for the status update. The context appears in
* GitHub as a sort of name for the check. It identifies a status check among the other status
* checks placed on the same commit.
* <p>
* The context name is specified as an argument to this step function. If that argument is
* omitted, however, it will fall back to the "Display Name" property of the GitHub project
* property of the build. Lastly, if that is also omitted, it will simply use the id/name of
* the project as the context name.
*/
private String resolveContext() {
if (isNotBlank(config.getContext())) {
return config.getContext();
}
GithubProjectProperty githubProperty = run.getParent().getProperty(GithubProjectProperty.class);
if (isNull(githubProperty) || isBlank(githubProperty.getDisplayName())) {
log.error("Unable to determine commit status context (the check name). "
+ "Argument 'context' not provided and no default configured. Using job name as fallback.");
return run.getParent().getFullName();
}
return githubProperty.getDisplayName();
}
示例11: forProject
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Nonnull
private static GitHubPRRepository forProject(Job<?, ?> job) throws IOException {
XmlFile configFile = new XmlFile(new File(job.getRootDir(), GitHubPRRepository.FILE));
GitHubPRTrigger trigger = ghPRTriggerFromJob(job);
requireNonNull(trigger, "Can't extract PR trigger from " + job.getFullName());
final GitHubRepositoryName repoFullName = trigger.getRepoFullName(job); // ask with job because trigger may not yet be started
GithubProjectProperty property = job.getProperty(GithubProjectProperty.class);
String githubUrl = property.getProjectUrl().toString();
GitHubPRRepository localRepository;
if (configFile.exists()) {
try {
localRepository = (GitHubPRRepository) configFile.read();
} catch (IOException e) {
LOGGER.info("Can't read saved repository, re-creating new one", e);
localRepository = new GitHubPRRepository(repoFullName.toString(), new URL(githubUrl));
}
} else {
localRepository = new GitHubPRRepository(repoFullName.toString(), new URL(githubUrl));
}
localRepository.setJob(job);
localRepository.setConfigFile(configFile);
try {
localRepository.actualise(trigger.getRemoteRepository());
localRepository.save();
} catch (Throwable ignore) {
//silently try actualise
}
return localRepository;
}
示例12: forProject
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Nonnull
private static GitHubBranchRepository forProject(Job<?, ?> job) throws IOException {
XmlFile configFile = new XmlFile(new File(job.getRootDir(), GitHubBranchRepository.FILE));
GitHubBranchTrigger trigger = ghBranchTriggerFromJob(job);
requireNonNull(trigger, "Can't extract Branch trigger from " + job.getFullName());
final GitHubRepositoryName repoFullName = trigger.getRepoFullName(job); // ask with job because trigger may not yet be started
GithubProjectProperty property = job.getProperty(GithubProjectProperty.class);
String githubUrl = property.getProjectUrl().toString();
GitHubBranchRepository localRepository;
if (configFile.exists()) {
try {
localRepository = (GitHubBranchRepository) configFile.read();
} catch (IOException e) {
LOGGER.info("Can't read saved repository, re-creating new one", e);
localRepository = new GitHubBranchRepository(repoFullName.toString(), new URL(githubUrl));
}
} else {
LOGGER.info("Creating new Branch Repository for '{}'", job.getFullName());
localRepository = new GitHubBranchRepository(repoFullName.toString(), new URL(githubUrl));
}
// set transient cached fields
localRepository.setJob(job);
localRepository.setConfigFile(configFile);
try {
localRepository.actualise(trigger.getRemoteRepository());
localRepository.save();
} catch (Throwable ignore) {
//silently try actualise
}
return localRepository;
}
示例13: checkBuildDataAbsenceAfterBuild
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的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);
}
示例14: shouldParseRepoNameFromProp
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Test
public void shouldParseRepoNameFromProp() throws IOException, ANTLRException {
FreeStyleProject p = j.createFreeStyleProject();
String org = "org";
String repo = "repo";
p.addProperty(new GithubProjectProperty(format("https://github.com/%s/%s", org, repo)));
GitHubRepositoryName fullName = defaultGitHubPRTrigger().getRepoFullName(p);
assertThat(fullName.getUserName(), equalTo(org));
assertThat(fullName.getRepositoryName(), equalTo(repo));
}
示例15: shouldTriggerJobOnPullRequestOpen
import com.coravy.hudson.plugins.github.GithubProjectProperty; //导入依赖的package包/类
@Test
public void shouldTriggerJobOnPullRequestOpen() throws Exception {
when(trigger.getRepoFullName(any(AbstractProject.class))).thenReturn(create(REPO_URL_FROM_PAYLOAD));
when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS);
FreeStyleProject job = jenkins.createFreeStyleProject();
job.addProperty(new GithubProjectProperty(REPO_URL_FROM_PAYLOAD));
job.addTrigger(trigger);
new GHPullRequestSubscriber().onEvent(GHEvent.PULL_REQUEST, classpath("payload/pull_request.json"));
verify(trigger).queueRun(eq(job), eq(1));
}