/** * If this project is configured to be always built on this node, * return that {@link Node}. Otherwise null. */ public @CheckForNull Label getAssignedLabel() { if(canRoam) return null; if(assignedNode==null) return Jenkins.getInstance().getSelfLabel(); return Jenkins.getInstance().getLabel(assignedNode); }
/** * Sets the assigned label. */ public void setAssignedLabel(Label l) throws IOException { if(l==null) { canRoam = true; assignedNode = null; } else { canRoam = false; if(l== Jenkins.getInstance().getSelfLabel()) assignedNode = null; else assignedNode = l.getExpression(); } save(); }
@Exported public LoadStatistics getLoadStatistics() { return LabelAtom.get(nodeName != null ? nodeName : Jenkins.getInstance().getSelfLabel().toString()).loadStatistics; }
if (lbl != null && lbl.equals(h.getSelfLabel())) { if (h.canTake(p) == null) { return createFlyWeightTaskRunnable(p, h.toComputer());
/** * {@inheritDoc} */ @Override public Label getAssignedLabel() { Jenkins j = Jenkins.getInstanceOrNull(); if (j == null) { return null; } return j.getSelfLabel(); }
@SuppressFBWarnings(value="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification="TODO 1.653+ switch to Jenkins.getInstanceOrNull") @Override public Label getAssignedLabel() { Jenkins j = Jenkins.getInstance(); if (j == null) { return null; } return j.getSelfLabel(); }
/** * {@inheritDoc} */ @Override public Label getAssignedLabel() { Jenkins j = Jenkins.getInstance(); if (j == null) { return null; } return j.getSelfLabel(); }
@Override public Label getAssignedLabel() { if (label == null) { return null; } else if (label.isEmpty()) { Jenkins j = Jenkins.getInstance(); if (j == null) { return null; } return j.getSelfLabel(); } else { return Label.get(label); } }
@SuppressFBWarnings(value="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification="TODO 1.653+ switch to Jenkins.getInstanceOrNull") @Override public Label getAssignedLabel() { if (label == null) { return null; } else if (label.isEmpty()) { Jenkins j = Jenkins.getInstance(); if (j == null) { return null; } return j.getSelfLabel(); } else { return Label.get(label); } }
@Override public Label getAssignedLabel() { if (label == null) { return null; } else if (label.isEmpty()) { Jenkins j = Jenkins.getInstance(); if (j == null) { return null; } return j.getSelfLabel(); } else { return Label.get(label); } }
/** * If this project is configured to be always built on this node, * return that {@link Node}. Otherwise null. */ public @CheckForNull Label getAssignedLabel() { if(canRoam) return null; if(assignedNode==null) return Jenkins.getInstance().getSelfLabel(); return Jenkins.getInstance().getLabel(assignedNode); }
/** * Sets the assigned label. */ public void setAssignedLabel(Label l) throws IOException { if(l==null) { canRoam = true; assignedNode = null; } else { canRoam = false; if(l== Jenkins.getInstance().getSelfLabel()) assignedNode = null; else assignedNode = l.getExpression(); } save(); }
@Override public Action getAction(AbstractBuild<?, ?> build, TaskListener listener) throws IOException, InterruptedException, DontTriggerException { Node node = build.getBuiltOn(); Label nodeLabel; // master does not return a node name so add it explicitly. if(node == null) { nodeLabel = Jenkins.getInstance().getSelfLabel(); } else { nodeLabel = node.getSelfLabel(); } listener.getLogger().println("Returning node parameter for " + nodeLabel.getDisplayName()); return new NodeAction(nodeLabel); }
@Exported public LoadStatistics getLoadStatistics() { return LabelAtom.get(nodeName != null ? nodeName : Jenkins.getInstance().getSelfLabel().toString()).loadStatistics; }
/** * Manufactures commits by adding files in the given names. */ private void createCommit(SubversionSCM scm, String... paths) throws Exception { FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject)null); List<File> added = new ArrayList<>(); for (String path : paths) { FilePath newFile = b.getWorkspace().child(path); added.add(new File(newFile.getRemote())); if (!newFile.exists()) { newFile.touch(System.currentTimeMillis()); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); } else newFile.write("random content","UTF-8"); } SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(added.toArray(new File[added.size()]),false,"added",null,null,false,false,SVNDepth.EMPTY); }
/** * Manufactures commits including metadata * @return */ private void createWorkingCopy(SubversionSCM scm) throws Exception { FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); workingcopy = b.getWorkspace(); }
@Test public void masterPolling() throws Exception { File repo = new CopyExisting(getClass().getResource("two-revisions.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + repo.toURI().toURL().getPath()); scm.setPollFromMaster(true); FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(2).get()); // initial polling on the master for the code path that doesn't find any change assertFalse(p.poll(StreamTaskListener.fromStdout()).hasChanges()); // create a commit FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); FilePath newFile = b.getWorkspace().child("foo"); newFile.touch(System.currentTimeMillis()); SvnClientManager svnm = SubversionSCM.createClientManager(p); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(new File[]{new File(newFile.getRemote())},false,"added",null,null,false,false,SVNDepth.INFINITY); // polling on the master for the code path that doesn't find any change assertTrue(p.poll(StreamTaskListener.fromStdout()).hasChanges()); }