本文整理汇总了Java中hudson.model.AbstractProject类的典型用法代码示例。如果您正苦于以下问题:Java AbstractProject类的具体用法?Java AbstractProject怎么用?Java AbstractProject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractProject类属于hudson.model包,在下文中一共展示了AbstractProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jobLoaded
import hudson.model.AbstractProject; //导入依赖的package包/类
@Initializer(before = InitMilestone.COMPLETED, after = InitMilestone.JOB_LOADED)
public static void jobLoaded() throws IOException
{
m_logger.fine("Initialization milestone: All jobs have been loaded"); //$NON-NLS-1$
Jenkins jenkins = Jenkins.getInstance();
for (AbstractProject<?, ?> project : jenkins.getAllItems(AbstractProject.class))
{
try
{
SCM scmConfig = project.getScm();
if (scmConfig instanceof AbstractConfiguration && ((AbstractConfiguration) scmConfig).isMigrated())
{
project.save();
m_logger.info(String.format(
"Project %s has been migrated.", //$NON-NLS-1$
project.getFullName()));
}
}
catch (IOException e)
{
m_logger.log(Level.SEVERE, String.format("Failed to upgrade job %s", project.getFullName()), e); //$NON-NLS-1$
}
}
}
示例2: doCheckLocalPath
import hudson.model.AbstractProject; //导入依赖的package包/类
public FormValidation doCheckLocalPath(@AncestorInPath final AbstractProject project,
@QueryParameter final String localPath) {
final String path = Util.fixEmptyAndTrim(localPath);
if (StringUtils.isBlank(path)) {
return FormValidation.ok();
}
try {
File f = resolvePath(project, localPath);
if (f != null) {
return FormValidation.ok();
}
} catch (Exception e) {
return FormValidation.error(e.getMessage());
}
return FormValidation.error("Invalid path.");
}
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:19,代码来源:BrowserStackBuildWrapperDescriptor.java
示例3: testGetProjectActionHavingLastBuildGivesStarWarsAction
import hudson.model.AbstractProject; //导入依赖的package包/类
public void testGetProjectActionHavingLastBuildGivesStarWarsAction() {
AbstractProject mockProject = mock(AbstractProject.class);
Build mockBuild = mock(Build.class);
Quote expectedQuote = generateQuote(StarWarsResult.SUCCESS);
when(mockProject.getLastBuild()).thenReturn(mockBuild);
when(mockBuild.getResult()).thenReturn(Result.SUCCESS);
when(mockQuotesGenerator.generate(StarWarsResult.SUCCESS)).thenReturn(expectedQuote);
Action action = recorder.getProjectAction(mockProject);
assertTrue(action instanceof StarWarsAction);
assertEquals(StarWarsResult.SUCCESS, ((StarWarsAction) action).getResult());
assertNotNull(((StarWarsAction) action).getQuote());
}
示例4: Ghprc
import hudson.model.AbstractProject; //导入依赖的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);
}
示例5: triggerFrom
import hudson.model.AbstractProject; //导入依赖的package包/类
/**
* support matrix plugin.
*
* @see JobInfoHelpers#triggerFrom(hudson.model.Job, java.lang.Class)
*/
@CheckForNull
public static <T extends Trigger> T triggerFrom(final Job<?, ?> job, Class<T> tClass) {
Job<?, ?> guessJob;
if (job instanceof MatrixConfiguration) {
guessJob = ((MatrixConfiguration) job).getParent();
} else {
guessJob = job;
}
if (guessJob instanceof AbstractProject<?, ?>) {
final AbstractProject<?, ?> abstractProject = (AbstractProject<?, ?>) guessJob;
return abstractProject.getTrigger(tClass);
} else if (guessJob instanceof ParameterizedJobMixIn.ParameterizedJob) {
ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) guessJob;
for (Trigger candidate : pJob.getTriggers().values()) {
if (tClass.isInstance(candidate)) {
return tClass.cast(candidate);
}
}
}
return null;
}
示例6: getWebHooks
import hudson.model.AbstractProject; //导入依赖的package包/类
private Set<GhprcWebHook> getWebHooks() {
final Set<GhprcWebHook> webHooks = new HashSet<GhprcWebHook>();
// We need this to get access to list of repositories
Authentication old = SecurityContextHolder.getContext().getAuthentication();
SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM);
try {
for (AbstractProject<?, ?> job : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
GhprcTrigger trigger = job.getTrigger(GhprcTrigger.class);
if (trigger == null || trigger.getWebHook() == null) {
continue;
}
webHooks.add(trigger.getWebHook());
}
} finally {
SecurityContextHolder.getContext().setAuthentication(old);
}
if (webHooks.size() == 0) {
logger.log(Level.WARNING, "No projects found using GitHub pull request trigger");
}
return webHooks;
}
示例7: compareRemoteRevisionWith
import hudson.model.AbstractProject; //导入依赖的package包/类
@Override
protected PollingResult compareRemoteRevisionWith(
final AbstractProject<?, ?> project,
final Launcher launcher,
final FilePath filePath,
final TaskListener listener,
final SCMRevisionState revisionState)
throws IOException, InterruptedException {
final ActionTypeId actionTypeId = new ActionTypeId()
.withCategory(actionTypeCategory)
.withOwner(ActionOwner.Custom)
.withProvider(actionTypeProvider)
.withVersion(actionTypeVersion);
LoggingHelper.log(listener, "Polling for jobs for action type id: ["
+ "Owner: %s, Category: %s, Provider: %s, Version: %s, ProjectName: %s]",
actionTypeId.getOwner(),
actionTypeId.getCategory(),
actionTypeId.getProvider(),
actionTypeId.getVersion(),
projectName);
return pollForJobs(actionTypeId, listener);
}
示例8: gatherEnvVarsNode
import hudson.model.AbstractProject; //导入依赖的package包/类
@Nonnull
private static Map<String, String> gatherEnvVarsNode(@Nonnull Job<?, ?> job, @Nonnull Node node) throws EnvInjectException {
final FilePath rootPath = node.getRootPath();
if (rootPath == null) {
//TODO: better than the original NPE. But maybe it's preferable to have more intelligent handling
throw new EnvInjectException("Cannot retrieve Environment variables from the offline node");
}
try {
Map<String, String> envVars = new EnvVars(rootPath.act(new MasterToSlaveCallable<Map<String, String>, EnvInjectException>() {
private static final long serialVersionUID = 1L;
@Override
public Map<String, String> call() throws EnvInjectException {
return EnvVars.masterEnvVars;
}
}));
envVars.put("NODE_NAME", node.getNodeName());
envVars.put("NODE_LABELS", Util.join(node.getAssignedLabels(), " "));
if (job instanceof AbstractProject) {
FilePath wFilePath = ((AbstractProject)job).getSomeWorkspace();
if (wFilePath != null) {
envVars.put("WORKSPACE", wFilePath.getRemote());
}
}
return envVars;
} catch (IOException | InterruptedException ioe) {
throw new EnvInjectException(ioe);
}
}
示例9: createSqsJob
import hudson.model.AbstractProject; //导入依赖的package包/类
@Override
public SQSJob createSqsJob(Job job, SQSTrigger sqsTrigger) {
SQSJob sqsJob = null;
if (job instanceof AbstractProject) {
sqsJob = new SQSAbstractProjectJob((AbstractProject) job, sqsTrigger);
}
else if (job instanceof WorkflowJob) {
sqsJob = new SQSWorkflowJob((WorkflowJob) job, sqsTrigger);
}
return sqsJob;
}
示例10: isApplicable
import hudson.model.AbstractProject; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public boolean isApplicable(Class<? extends AbstractProject> aClass)
{
// Indicates that this builder can be used with all kinds of project types
return true;
}
示例11: compareRemoteRevisionWith
import hudson.model.AbstractProject; //导入依赖的package包/类
/**
* See documentation top of class
* This function will determine the state of the artifactory server and compare it with the
* local state. If there is a condition where a build needs to be triggered, trigger a build
*/
@Override
public PollingResult compareRemoteRevisionWith(AbstractProject<?,?> project,
Launcher launcher, FilePath workspace, TaskListener listener,
SCMRevisionState baseline) throws IOException, InterruptedException
{
LOGGER.log(FINE, "Comparing remote revisions with baseline");
ArtifactoryRevisionState localState = (ArtifactoryRevisionState) baseline;
ArtifactoryAPI api = new ArtifactoryAPI(getDescriptor().getArtifactoryServer());
ArtifactoryRevisionState serverState = ArtifactoryRevisionState.fromServer(repo, groupID, artifactID, versionFilter, api);
//Compare server state to local state
nextArtifact = ArtifactoryRevisionState.compareRevisionStates(serverState, localState);
if (nextArtifact != null)
{
LOGGER.log(FINE, "Found new data for version: " + nextArtifact);
return PollingResult.BUILD_NOW;
}
// Compare local state to server state
nextArtifact = ArtifactoryRevisionState.compareRevisionStates(localState, serverState);
if (nextArtifact != null)
{
LOGGER.log(FINE, "Found new data for version: " + nextArtifact);
return PollingResult.BUILD_NOW;
}
return PollingResult.NO_CHANGES;
}
示例12: dir
import hudson.model.AbstractProject; //导入依赖的package包/类
@Override
protected File dir() {
if (item instanceof AbstractProject) {
Run<?, ?> run = getAbstractProject().getLastCompletedBuild();
if (run != null) {
File buildArchiveDir = getBuildArchiveDir(run);
if (buildArchiveDir.exists()) {
return buildArchiveDir;
}
}
}
return getProjectArchiveDir(item);
}
示例13: testUploadSource
import hudson.model.AbstractProject; //导入依赖的package包/类
@Test
public void testUploadSource() throws Exception {
SCM mockSCM = mock(SCM.class);
when(mockSCM.getType()).thenReturn("SCM");
AbstractProject p = mock(AbstractProject.class);
when(p.getScm()).thenReturn(mockSCM);
when(build.getProject()).thenReturn(p);
S3DataManager d = createDefaultSource();
File sourceFolder = new File("/tmp/jenkins/workspace/proj");
sourceFolder.mkdirs();
UploadToS3Output result = d.uploadSourceToS3(listener, testWorkSpace);
assertEquals(result.getSourceLocation(), s3InputBucketName + "/" + s3InputKeyName);
}
示例14: notifyStart
import hudson.model.AbstractProject; //导入依赖的package包/类
private void notifyStart(AbstractBuild build, String message) {
try {
AbstractProject<?, ?> project = build.getProject();
AbstractBuild<?, ?> previousBuild = project.getLastBuild().getPreviousCompletedBuild();
getTelegram(build).publish(message, getBuildColor(previousBuild));
}
catch (NullPointerException npe){
getTelegram(build).publish(message, "good");
}
}
示例15: completed
import hudson.model.AbstractProject; //导入依赖的package包/类
public void completed(AbstractBuild r) {
AbstractProject<?, ?> project = r.getProject();
if(project == null) return;
Result result = r.getResult();
AbstractBuild<?, ?> previousBuild = project.getLastBuild();
if(previousBuild == null) return;
do {
previousBuild = previousBuild.getPreviousCompletedBuild();
} while (previousBuild != null && previousBuild.getResult() == Result.ABORTED);
Result previousResult = (previousBuild != null) ? previousBuild.getResult() : Result.SUCCESS;
if ((result == Result.ABORTED && notifier.getNotifyAborted())
|| (result == Result.FAILURE //notify only on single failed build
&& previousResult != Result.FAILURE
&& notifier.getNotifyFailure())
|| (result == Result.FAILURE //notify only on repeated failures
&& previousResult == Result.FAILURE
&& notifier.getNotifyRepeatedFailure())
|| (result == Result.NOT_BUILT && notifier.getNotifyNotBuilt())
|| (result == Result.SUCCESS
&& (previousResult == Result.FAILURE || previousResult == Result.UNSTABLE)
&& notifier.getNotifyBackToNormal())
|| (result == Result.SUCCESS && notifier.getNotifySuccess())
|| (result == Result.UNSTABLE && notifier.getNotifyUnstable())) {
getTelegram(r).publish(getBuildStatusMessage(r, notifier.includeTestSummary(),
notifier.getIncludeFailedTests(),notifier.includeCustomMessage()), getBuildColor(r));
}
}