• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Items类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中hudson.model.Items的典型用法代码示例。如果您正苦于以下问题:Java Items类的具体用法?Java Items怎么用?Java Items使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Items类属于hudson.model包,在下文中一共展示了Items类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: packageRenameConverting

import hudson.model.Items; //导入依赖的package包/类
@Initializer(before = InitMilestone.JOB_LOADED)
@Restricted(NoExternalUse.class)
public static void packageRenameConverting() {
    for(XStream2 xs : Arrays.asList(Items.XSTREAM2, Run.XSTREAM2, Jenkins.XSTREAM2, getFingerprintXStream())) {
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.DockerHubTrigger",
                                 DockerHubTrigger.class);
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.DockerHubWebHookCause",
                                 DockerHubWebHookCause.class);
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.DockerPullImageBuilder",
                                 DockerPullImageBuilder.class);
        //TODO no back-compat tests for the column and filter
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerListViewColumn",
                                 TriggerListViewColumn.class);
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerViewFilter",
                                 TriggerViewFilter.class);
        //The TriggerOption extension point has also changed package name and will not be backwards compatible API
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.opt.impl.TriggerForAllUsedInJob",
                                 TriggerForAllUsedInJob.class);
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.opt.impl.TriggerOnSpecifiedImageNames",
                                 TriggerOnSpecifiedImageNames.class);
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerStore$TriggerEntry",
                                 TriggerStore.TriggerEntry.class);
        xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerStore$TriggerEntry$RunEntry",
                                 TriggerStore.TriggerEntry.RunEntry.class);
    }
}
 
开发者ID:jenkinsci,项目名称:dockerhub-notification-plugin,代码行数:27,代码来源:DockerHubTrigger.java


示例2: getProjectList

import hudson.model.Items; //导入依赖的package包/类
public static List<AbstractProject> getProjectList(String projects, ItemGroup context, EnvVars env) {
    List<AbstractProject> projectList = new ArrayList<>();

    // expand variables if applicable
    StringBuilder projectNames = new StringBuilder();
    StringTokenizer tokens = new StringTokenizer(projects, ",");
    while (tokens.hasMoreTokens()) {
        if (projectNames.length() > 0) {
            projectNames.append(',');
        }
        projectNames.append(env != null ? env.expand(tokens.nextToken().trim()) : tokens.nextToken().trim());
    }

    projectList.addAll(Items.fromNameList(context, projectNames.toString(), AbstractProject.class));
    return projectList;
}
 
开发者ID:Diabol,项目名称:delivery-pipeline-plugin,代码行数:17,代码来源:ProjectUtil.java


示例3: doCheck

import hudson.model.Items; //导入依赖的package包/类
/**
 * Form validation method.  Similar to
 * {@link hudson.tasks.BuildTrigger.DescriptorImpl#doCheck(AbstractProject, String)}.
 *
 * @param folder the folder being configured
 * @param value  the user-entered value
 * @return validation result
 */
public FormValidation doCheck(@AncestorInPath AbstractFolder folder, @QueryParameter String value) {
    // Require CONFIGURE permission on this project
    if (!folder.hasPermission(Item.CONFIGURE)) {
        return FormValidation.ok();
    }

    boolean hasJobs = false;

    StringTokenizer tokens = new StringTokenizer(Util.fixNull(value), ",");
    while (tokens.hasMoreTokens()) {
        String jobName = tokens.nextToken().trim();

        if (StringUtils.isNotBlank(jobName)) {
            Item item = Jenkins.getActiveInstance().getItem(jobName, (ItemGroup) folder, Item.class);

            if (item == null) {
                Job nearest = Items.findNearest(Job.class, jobName, folder);
                String alternative = nearest != null ? nearest.getRelativeNameFrom((ItemGroup) folder) : "?";
                return FormValidation.error(
                        hudson.tasks.Messages.BuildTrigger_NoSuchProject(jobName, alternative));
            }

            if (!(item instanceof Job)) {
                return FormValidation.error(hudson.tasks.Messages.BuildTrigger_NotBuildable(jobName));
            }

            hasJobs = true;
        }
    }

    if (!hasJobs) {
        return FormValidation.error(hudson.tasks.Messages.BuildTrigger_NoProjectSpecified());
    }

    return FormValidation.ok();
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:45,代码来源:SelectJobsBallColorFolderIcon.java


示例4: init3

import hudson.model.Items; //导入依赖的package包/类
/**
 * Common initialization that is invoked when either a new project is created with the constructor
 * {@link TemplateDrivenMultiBranchProject#TemplateDrivenMultiBranchProject(ItemGroup, String)} or when a project
 * is loaded from disk with {@link #onLoad(ItemGroup, String)}.
 */
protected void init3() {
    if (disabledSubProjects == null) {
        disabledSubProjects = new PersistedList<>(this);
    }

    // Owner doesn't seem to be set when loading from XML
    disabledSubProjects.setOwner(this);

    try {
        XmlFile templateXmlFile = Items.getConfigFile(getTemplateDir());
        if (templateXmlFile.getFile().isFile()) {
            /*
             * Do not use Items.load here, since it uses getRootDirFor(i) during onLoad,
             * which returns the wrong location since template would still be unset.
             * Instead, read the XML directly into template and then invoke onLoad.
             */
            //noinspection unchecked
            template = (P) templateXmlFile.read();
            template.onLoad(this, TEMPLATE);
        } else {
            /*
             * Don't use the factory here because newInstance calls setBranch, attempting
             * to save the project before template is set.  That would invoke
             * getRootDirFor(i) and get the wrong directory to save into.
             */
            template = newTemplate();
        }

        // Prevent tampering
        if (!(template.getScm() instanceof NullSCM)) {
            template.setScm(new NullSCM());
        }
        template.disable();
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Failed to load template project " + getTemplateDir(), e);
    }
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:43,代码来源:TemplateDrivenMultiBranchProject.java


示例5: updateByXml

import hudson.model.Items; //导入依赖的package包/类
/**
 * This is a mirror of {@link hudson.model.AbstractItem#updateByXml(Source)} without the
 * {@link hudson.model.listeners.SaveableListener#fireOnChange(Saveable, XmlFile)} trigger.
 *
 * @param project project to update by XML
 * @param source  source of XML
 * @throws IOException if error performing update
 */
@SuppressWarnings("ThrowFromFinallyBlock")
private void updateByXml(final P project, Source source) throws IOException {
    project.checkPermission(Item.CONFIGURE);
    final String projectName = project.getName();
    XmlFile configXmlFile = project.getConfigFile();
    final AtomicFileWriter out = new AtomicFileWriter(configXmlFile.getFile());
    try {
        try {
            XMLUtils.safeTransform(source, new StreamResult(out));
            out.close();
        } catch (SAXException | TransformerException e) {
            throw new IOException("Failed to persist config.xml", e);
        }

        // try to reflect the changes by reloading
        Object o = new XmlFile(Items.XSTREAM, out.getTemporaryFile()).unmarshal(project);
        if (o != project) {
            // ensure that we've got the same job type. extending this code to support updating
            // to different job type requires destroying & creating a new job type
            throw new IOException("Expecting " + project.getClass() + " but got " + o.getClass() + " instead");
        }

        Items.whileUpdatingByXml(new NotReallyRoleSensitiveCallable<Void, IOException>() {
            @SuppressWarnings("unchecked")
            @Override
            public Void call() throws IOException {
                project.onLoad(project.getParent(), projectName);
                return null;
            }
        });
        Jenkins.getActiveInstance().rebuildDependencyGraphAsync();

        // if everything went well, commit this new version
        out.commit();
    } finally {
        out.abort();
    }
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:47,代码来源:TemplateDrivenBranchProjectFactory.java


示例6: getProjectByName

import hudson.model.Items; //导入依赖的package包/类
/**
 * Get project in Jenkins given its name.
 *
 * @since 1.3
 * @param projectName project name in Jenkins
 * @return Project or {@code null} if none with this name
 * @deprecated The choice is arbitrary if there are multiple matches; use {@link Item#getFullName} and {@link Jenkins#getItemByFullName(String, Class)} instead.
 */
@SuppressWarnings("rawtypes")
public static @CheckForNull Project<?, ?> getProjectByName(@Nonnull String projectName) {
    Authentication auth = Jenkins.getAuthentication();
    for (Project p : Items.allItems(ACL.SYSTEM, Jenkins.getInstance(), Project.class)) {
        if (p.getName().equals(projectName) && p.getACL().hasPermission(auth, Item.READ)) {
            return p;
        }
    }
    return null;
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:19,代码来源:Utils.java


示例7: findProjectByParameterUUID

import hudson.model.Items; //导入依赖的package包/类
/**
 * Find the current project give its parameter UUID.
 *
 * @author dynamic-parameter-plugin
 * @since 1.3
 * @param parameterUUID parameter UUID
 * @return {@code null} if the current project cannot be found
 */
@SuppressWarnings("rawtypes")
public static @CheckForNull Project findProjectByParameterUUID(@Nonnull String parameterUUID) {
    Authentication auth = Jenkins.getAuthentication();
    for (Project p : Items.allItems(ACL.SYSTEM, Jenkins.getInstance(), Project.class)) {
        if (isParameterDefinitionOf(parameterUUID, p) && p.getACL().hasPermission(auth, Item.READ)) {
            return p;
        }
    }
    return null;
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:19,代码来源:Utils.java


示例8: initializeXStream

import hudson.model.Items; //导入依赖的package包/类
@Initializer(before=InitMilestone.PLUGINS_STARTED)
public static void initializeXStream() {
	InheritableParameterReferenceConverter conv = new InheritableParameterReferenceConverter();
	
	final XStream2[] xs = {
			Jenkins.XSTREAM2, Run.XSTREAM2, Items.XSTREAM2
	};
	for (XStream2 x : xs) {
		//Add the custom converter to hide some fields
		x.registerConverter(conv);
	}
}
 
开发者ID:i-m-c,项目名称:jenkins-inheritance-plugin,代码行数:13,代码来源:InheritableStringParameterReferenceDefinition.java


示例9: updateProjectWithXmlSource

import hudson.model.Items; //导入依赖的package包/类
/**
 * Copied from {@link AbstractProject#updateByXml(javax.xml.transform.Source)}, removing the save event and
 * returning the project after the update.
 */
@SuppressWarnings("unchecked")
public static AbstractProject updateProjectWithXmlSource(AbstractProject project, Source source) throws IOException {

    XmlFile configXmlFile = project.getConfigFile();
    AtomicFileWriter out = new AtomicFileWriter(configXmlFile.getFile());
    try {
        try {
            // this allows us to use UTF-8 for storing data,
            // plus it checks any well-formedness issue in the submitted
            // data
            Transformer t = TransformerFactory.newInstance()
                    .newTransformer();
            t.transform(source,
                    new StreamResult(out));
            out.close();
        } catch (TransformerException e) {
            throw new IOException2("Failed to persist configuration.xml", e);
        }

        // try to reflect the changes by reloading
        new XmlFile(Items.XSTREAM, out.getTemporaryFile()).unmarshal(project);
        project.onLoad(project.getParent(), project.getRootDir().getName());
        Jenkins.getInstance().rebuildDependencyGraph();

        // if everything went well, commit this new version
        out.commit();
        return ProjectUtils.findProject(project.getFullName());
    } finally {
        out.abort(); // don't leave anything behind
    }
}
 
开发者ID:JoelJ,项目名称:ez-templates,代码行数:36,代码来源:ProjectUtils.java


示例10: registerXStream

import hudson.model.Items; //导入依赖的package包/类
/**
 * Gives this class an alias for configuration XML.
 */
@Initializer(before = InitMilestone.PLUGINS_STARTED)
@SuppressWarnings(UNUSED)
public static void registerXStream() {
    Items.XSTREAM.alias("matrix-multi-branch-project", MatrixMultiBranchProject.class);
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:9,代码来源:MatrixMultiBranchProject.java


示例11: registerXStream

import hudson.model.Items; //导入依赖的package包/类
/**
 * Gives this class an alias for configuration XML.
 */
@SuppressWarnings(UNUSED)
@Initializer(before = InitMilestone.PLUGINS_STARTED)
public static void registerXStream() {
    Items.XSTREAM.alias("branch-list-view", BranchListView.class);
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:9,代码来源:BranchListView.java


示例12: registerXStream

import hudson.model.Items; //导入依赖的package包/类
/**
 * Gives this class an alias for configuration XML.
 */
@SuppressWarnings(UNUSED)
@Initializer(before = InitMilestone.PLUGINS_STARTED)
public static void registerXStream() {
    Items.XSTREAM.alias("ivy-multi-branch-project", IvyMultiBranchProject.class);
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:9,代码来源:IvyMultiBranchProject.java


示例13: registerXStream

import hudson.model.Items; //导入依赖的package包/类
/**
 * Gives this class an alias for configuration XML.
 */
@Initializer(before = InitMilestone.PLUGINS_STARTED)
@SuppressWarnings("unused")
public static void registerXStream() {
    Items.XSTREAM.alias("freestyle-multi-branch-project", FreeStyleMultiBranchProject.class);
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:9,代码来源:FreeStyleMultiBranchProject.java


示例14: registerXStream

import hudson.model.Items; //导入依赖的package包/类
/**
 * Gives this class an alias for configuration XML.
 */
@Initializer(before = InitMilestone.PLUGINS_STARTED)
@SuppressWarnings(UNUSED)
public static void registerXStream() {
    Items.XSTREAM.alias("maven-multi-branch-project", MavenMultiBranchProject.class);
}
 
开发者ID:jenkinsci,项目名称:multi-branch-project-plugin,代码行数:9,代码来源:MavenMultiBranchProject.java


示例15: start

import hudson.model.Items; //导入依赖的package包/类
@Override
public void start() throws Exception {
    Items.XSTREAM.registerConverter(new Config.ConverterImpl());
    load();
    LOG.fine("Loading config: " + config);
}
 
开发者ID:speedledger,项目名称:elasticsearch-jenkins,代码行数:7,代码来源:ElasticsearchPlugin.java


示例16: addAlias

import hudson.model.Items; //导入依赖的package包/类
@Initializer(before=InitMilestone.PLUGINS_STARTED)
public static void addAlias() {
    Items.XSTREAM2.addCompatibilityAlias("org.jenkinsci.plugins.awsbeanstalkpublisher.AWSEBDeploymentBuilder", AWSEBBuilder.class);
}
 
开发者ID:DavidTanner,项目名称:aws-beanstalk-publisher,代码行数:5,代码来源:AWSEBBuilder.java


示例17: addAlias

import hudson.model.Items; //导入依赖的package包/类
@Initializer(before=InitMilestone.PLUGINS_STARTED)
public static void addAlias() {
    Items.XSTREAM2.addCompatibilityAlias("org.jenkinsci.plugins.awsbeanstalkpublisher.AWSEBDeploymentPublisher", AWSEBPublisher.class);
}
 
开发者ID:DavidTanner,项目名称:aws-beanstalk-publisher,代码行数:5,代码来源:AWSEBPublisher.java


示例18: writeStableConfigDotXml

import hudson.model.Items; //导入依赖的package包/类
protected void writeStableConfigDotXml(OutputStream out)
		throws IOException, HttpStatusException {
	if (out == null) { return; }
	//Get the XML for the current project, as it'd be written to disk
	String selfXml = Items.XSTREAM2.toXML(this);
	//Then, loading it back, to get a modifiable copy
	Object obj = Items.XSTREAM2.fromXML(selfXml);
	if (!(obj instanceof InheritanceProject)) {
		throw new HttpStatusException(
				HttpStatus.SC_INTERNAL_SERVER_ERROR,
				"Error, could not (de-)serialize project"
		);
	}
	
	//Casting the project suitably, to access the needed fields
	InheritanceProject mod = (InheritanceProject) obj;
	
	/* Some alterations to the project wish to save it, for this to work, we
	 * need an ephemeral ItemGroup that serves as the container that can be
	 * cleaned, once it is not needed anymore
	 */
	MockItemGroup<Job<?,?>> mig = new MockItemGroup<>();
	
	try {
		//Giving the project a custom name and temporary item-group/directory
		UUID uuid = UUID.randomUUID();
		mod.onLoad(mig, uuid.toString());
		
		//Loaded project start without a VOB, so a blank one is created
		mod.versionStore = new VersionedObjectStore();
		
		//Replacing all versioned fields in the copy with the currently selected versions
		//NOTE: Actions can't be modified, since the parent class hides the field :(
		try {
			mod.copyVersionedSettingsFrom(this);
		} catch (IOException ex) {
			throw new HttpStatusException(
					HttpStatus.SC_INTERNAL_SERVER_ERROR,
					"Failed to produce XML for stable version", ex
			);
		}
		
		// Turning this modified project into an UTF8 XML and sending it to the client
		Items.XSTREAM2.toXMLUTF8(mod, out);
	} finally {
		//Purge the temporary item group with fire
		mig.clean();
	}
}
 
开发者ID:i-m-c,项目名称:jenkins-inheritance-plugin,代码行数:50,代码来源:InheritanceProject.java



注:本文中的hudson.model.Items类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XmlHighlighterColors类代码示例发布时间:2022-05-22
下一篇:
Java RpcRequestMessageWrapper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap