public void save() throws IOException { build.save(); }
/** * Called when the build is qualified. */ public synchronized boolean add(Status status) throws IOException { for (Status s : statuses) if(s.name.equals(status.name)) return false; // already qualified. noop. this.statuses.add(status); status.parent = this; owner.save(); return true; }
private void countAndSave(TestNGResult testngResults) { int savedPassCount = passCount != null ? passCount : -1; int savedFailCount = failCount; int savedSkipCount = skipCount; count(testngResults); if (passCount != savedPassCount || failCount != savedFailCount || skipCount != savedSkipCount) { LOGGER.log(Level.FINE, "saving {0}", owner); try { owner.save(); } catch (IOException x) { LOGGER.log(Level.WARNING, "failed to save " + owner, x); } } }
private void addJenkinsAction(AbstractBuild build, String dockerHost, String containerId, String tag_image) throws IOException { build.addAction(new DockerBuildAction(dockerHost, containerId, tag_image)); build.save(); }
public static void addBuildDiskUsageAction(AbstractBuild build){ BuildDiskUsageAction action = null; for(Action a: build.getActions()){ if(a instanceof BuildDiskUsageAction){ action = (BuildDiskUsageAction) a; break; } } if(action == null){ build.addAction(new BuildDiskUsageAction(build)); try { build.save(); } catch (IOException ex) { Logger.getLogger(DiskUsageUtil.class.getName()).log(Level.SEVERE, null, ex); } } } public static void calculateDiskUsageForBuild(String buildId, AbstractProject project)
private void saveIssues(AbstractBuild<?, ?> build, JiraBuildAction a, Set<JiraIssue> issuesToBeSaved) { if (a != null) { a.addIssues(issuesToBeSaved); } else { JiraBuildAction action = new JiraBuildAction(build, issuesToBeSaved); build.addAction(action); } try { build.save(); } catch (final IOException e) { LOGGER.log(Level.WARNING, "Error saving updated build", e); } }
public void save() throws IOException { if (!workspaceExists()) { build.getAction(WorkspaceConfiguration.class).setWorkspaceWasRemoved(); } build.save(); }
public synchronized HttpResponse doSubmitDescription( @QueryParameter String description) throws IOException, ServletException { if (getOwner() == null) { LOGGER.severe("getOwner() is null, can't save description."); } else { getOwner().checkPermission(Run.UPDATE); setDescription(description); getOwner().save(); } return new HttpRedirect("."); } private static final long serialVersionUID = 1L;
public synchronized HttpResponse doSubmitDescription( @QueryParameter String description) throws IOException, ServletException { if (getOwner() == null) { LOGGER.severe("getOwner() is null, can't save description."); } else { getOwner().checkPermission(Run.UPDATE); setDescription(description); getOwner().save(); } return new HttpRedirect("."); } private static final long serialVersionUID = 1L;
public synchronized HttpResponse doSubmitDescription( @QueryParameter String description) throws IOException, ServletException { if (getOwner() == null) { LOGGER.severe("getOwner() is null, can't save description."); } else { getOwner().checkPermission(Run.UPDATE); setDescription(description); getOwner().save(); } return new HttpRedirect("."); } private static final long serialVersionUID = 1L;
public synchronized HttpResponse doSubmitDescription( @QueryParameter String description) throws IOException, ServletException { if (getOwner() == null) { LOGGER.severe("getOwner() is null, can't save description."); } else { getOwner().checkPermission(Run.UPDATE); setDescription(description); getOwner().save(); } return new HttpRedirect("."); } private static final long serialVersionUID = 1L;
@CheckForNull public Future<Promotion> approve(AbstractBuild<?,?> build, PromotionProcess promotionProcess, List<ParameterValue> paramValues) throws IOException{ if (canApprove(promotionProcess, build)) { // add approval to build ManualApproval approval=new ManualApproval(promotionProcess.getName(), paramValues); build.addAction(approval); build.save(); // check for promotion return promotionProcess.considerPromotion2(build, approval); } return null; } public List<ParameterValue> createDefaultValues(){
@Override public final boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener) throws InterruptedException, IOException { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); LOGGER.fine("perform() called for script:\n" + groovyScript); BadgeManager badgeManager = new BadgeManager(build, listener); GroovyShell shell = new GroovyShell(); shell.setVariable("manager", badgeManager); try { shell.evaluate(groovyScript); } catch (Exception e) { e.printStackTrace(listener.error("Failed to evaluate groovy script.")); } for(AbstractBuild<?, ?> b : badgeManager.builds) { b.save(); } return build.getResult().isBetterThan(Result.FAILURE); }
public void tagBuild(String tagname, String description) throws IOException { tag = tagname; desc = description; Label label = new Label(); label.setName(tag); label.setDescription(desc); label.setRevision(new Integer(changeNumber).toString()); //Only take the depot paths and add them to the view. List<String> viewPairs = PerforceSCM.parseProjectPath(view, "workspace"); for (int i=0; i < viewPairs.size(); i+=2){ String depotPath = viewPairs.get(i); label.addView(depotPath); } try { depot.getLabels().saveLabel(label); } catch(PerforceException e) { tag = null; desc = null; e.printStackTrace(); throw new IOException("Failed to issue perforce label." + e.getMessage()); } build.save(); }
public synchronized void loadFirstTime(){ load(); buildDiskUsage = new HashSet<DiskUsageBuildInformation>(); List<Run> list = job.getBuilds(); for(Run run : list){ if(run instanceof AbstractBuild){ AbstractBuild build = (AbstractBuild) run; BuildDiskUsageAction usage = run.getAction(BuildDiskUsageAction.class); DiskUsageBuildInformation information = new DiskUsageBuildInformation(build.getId(), build.getTimeInMillis(), build.number, 0l); buildDiskUsage.add(information); if(usage==null){ run.getActions().add(new BuildDiskUsageAction(build)); try { build.save(); } catch (IOException ex) { Logger.getLogger(ProjectDiskUsage.class.getName()).log(Level.SEVERE, null, ex); } } else{ information.setSize(usage.buildDiskUsage); } DiskUsageUtil.addBuildDiskUsageAction(build); } } DiskUsageProperty property = (DiskUsageProperty) job.getProperty(DiskUsageProperty.class); property.checkWorkspaces(true); save(); }
/** * Promote the given build by using the given qualification. * * @param build Build to promote * @param cause Why the build is promoted? * @param qualification Initial promotion status * @param params Promotion parameters * @return Future to track the completion of the promotion. * @throws IOException Promotion failure */ public Future<Promotion> promote2(AbstractBuild<?,?> build, Cause cause, Status qualification, List<ParameterValue> params) throws IOException { PromotedBuildAction a = build.getAction(PromotedBuildAction.class); // build is qualified for a promotion. if(a!=null) { a.add(qualification); } else { build.addAction(new PromotedBuildAction(build,qualification)); build.save(); } // schedule promotion activity. return scheduleBuild2(build,cause, params); }
protected void perform(TaskListener listener) throws Exception { try { MavenEmbedder embedder = MavenUtil.createEmbedder(listener,getBuild()); ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) embedder.lookup( ArtifactRepositoryLayout.class,"default"); ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) embedder.lookup(ArtifactRepositoryFactory.ROLE); ArtifactRepository repository = factory.createDeploymentArtifactRepository( id, repositoryUrl, layout, uniqueVersion); WrappedArtifactRepository repo = new WrappedArtifactRepository(repository, uniqueVersion); deploy(embedder,repo,listener); record.result = Result.SUCCESS; } finally { if(record.result==null) record.result = Result.FAILURE; // persist the record getBuild().save(); } } }.start();
protected void perform(TaskListener listener) throws Exception { try { MavenEmbedder embedder = MavenUtil.createEmbedder(listener,getBuild()); ArtifactRepositoryLayout layout = embedder.lookup( ArtifactRepositoryLayout.class,"default"); ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) embedder.lookup(ArtifactRepositoryFactory.ROLE); ArtifactRepository repository = factory.createDeploymentArtifactRepository( id, repositoryUrl, layout, uniqueVersion); WrappedArtifactRepository repo = new WrappedArtifactRepository(repository, uniqueVersion); deploy(embedder,repo,listener); record.result = Result.SUCCESS; } finally { if(record.result==null) record.result = Result.FAILURE; // persist the record getBuild().save(); } } }.start();
protected void post2(BuildListener listener) throws Exception { if (getTarget() == null) { listener.error("No Promotion target, cannot save target or update status"); return; } if(getResult()== Result.SUCCESS) getStatus().onSuccessfulPromotion(Promotion.this); // persist the updated build record getTarget().save(); if (getResult() == Result.SUCCESS) { // we should evaluate any other pending promotions in case // they had a condition on this promotion PromotedBuildAction pba = getTarget().getAction(PromotedBuildAction.class); for (PromotionProcess pp : pba.getPendingPromotions()) { pp.considerPromotion2(getTarget()); } // tickle PromotionTriggers for (AbstractProject<?,?> p : JenkinsHelper.getInstance().getAllItems(AbstractProject.class)) { PromotionTrigger pt = p.getTrigger(PromotionTrigger.class); if (pt!=null) pt.consider(Promotion.this); } } }