Java Code Examples for hudson.model.AbstractProject#removeProperty()
The following examples show how to use
hudson.model.AbstractProject#removeProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PromotedBuildsTemplateUtils.java From ez-templates with Apache License 2.0 | 5 votes |
/** * Adds all the promotions from the template project into the implementation one. All existing promotions from the * implementation project are lost. * * @param implementationProject * @param templateProject * @throws IOException */ public static void addPromotions(AbstractProject implementationProject, AbstractProject templateProject) throws IOException { JobPropertyImpl promotions = (JobPropertyImpl) implementationProject.getProperty(JobPropertyImpl.class); if (promotions != null) { LOG.info(String.format("Merging [%s].", promotions.getFullDisplayName())); // remove existing promotions on implementationProject, if any implementationProject.removeProperty(JobPropertyImpl.class); Util.deleteRecursive(new File(implementationProject.getRootDir(), "promotions")); promotions.getItems().clear(); // obtain templateProject promotions. Each promotion is stored under a different folder under $JOB/promotions File templatePromotions = new File(templateProject.getRootDir(), "promotions"); String[] list = templatePromotions.list(); if (list != null) { for (String promotionDir : list) { File templatePromotionProcess = new File(templatePromotions, promotionDir); if (templatePromotionProcess.isDirectory()) { // for each promotion, create a process from its configuration promotions.createProcessFromXml(promotionDir, new FileInputStream(new File(templatePromotionProcess, "config.xml"))); } } } // update implementationProject with the resulting promotions implementationProject.addProperty(promotions); } }
Example 2
Source File: MattermostNotifier.java From jenkins-mattermost-plugin with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public void onLoaded() { logger.info("Starting Settings Migration Process"); for (AbstractProject<?, ?> p : Jenkins.getInstance().getAllItems(AbstractProject.class)) { final MattermostJobProperty mattermostJobProperty = p.getProperty(MattermostJobProperty.class); if (mattermostJobProperty == null) { logger.fine( String.format( "Configuration is already up to date for \"%s\", skipping migration", p.getName())); continue; } MattermostNotifier mattermostNotifier = p.getPublishersList().get(MattermostNotifier.class); if (mattermostNotifier == null) { logger.fine( String.format( "Configuration does not have a notifier for \"%s\", not migrating settings", p.getName())); } else { logger.info(String.format("Starting migration for \"%s\"", p.getName())); // map settings if (StringUtils.isBlank(mattermostNotifier.getEndpoint().getPlainText())) { mattermostNotifier.setEndpoint(mattermostJobProperty.getEndpoint()); } if (StringUtils.isBlank(mattermostNotifier.icon)) { mattermostNotifier.icon = mattermostJobProperty.getIcon(); } if (StringUtils.isBlank(mattermostNotifier.room)) { mattermostNotifier.room = mattermostJobProperty.getRoom(); } mattermostNotifier.startNotification = mattermostJobProperty.getStartNotification(); mattermostNotifier.notifyAborted = mattermostJobProperty.getNotifyAborted(); mattermostNotifier.notifyFailure = mattermostJobProperty.getNotifyFailure(); mattermostNotifier.notifyNotBuilt = mattermostJobProperty.getNotifyNotBuilt(); mattermostNotifier.notifySuccess = mattermostJobProperty.getNotifySuccess(); mattermostNotifier.notifyUnstable = mattermostJobProperty.getNotifyUnstable(); mattermostNotifier.notifyBackToNormal = mattermostJobProperty.getNotifyBackToNormal(); mattermostNotifier.notifyRepeatedFailure = mattermostJobProperty.getNotifyRepeatedFailure(); mattermostNotifier.includeTestSummary = mattermostJobProperty.includeTestSummary(); mattermostNotifier.commitInfoChoice = mattermostJobProperty.getShowCommitList() ? CommitInfoChoice.AUTHORS_AND_TITLES : CommitInfoChoice.NONE; mattermostNotifier.includeCustomAttachmentMessage = mattermostJobProperty.includeCustomAttachmentMessage(); mattermostNotifier.customAttachmentMessage = mattermostJobProperty.getCustomAttachmentMessage(); mattermostNotifier.includeCustomMessage = mattermostJobProperty.includeCustomMessage(); mattermostNotifier.customMessage = mattermostJobProperty.getCustomMessage(); } try { // property section is not used anymore - remove p.removeProperty(MattermostJobProperty.class); p.save(); logger.info("Configuration updated successfully"); } catch (IOException e) { logger.log(Level.SEVERE, e.getMessage(), e); } } }