本文整理汇总了Java中hudson.model.Items类的典型用法代码示例。如果您正苦于以下问题:Java Items类的具体用法?Java Items怎么用?Java Items使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Items类属于hudson.model包,在下文中一共展示了Items类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}