/** * Can be overridden if needed */ @Override protected void start(Node pollingNode, BuildableItem project, boolean newInstance, XTriggerLog log) throws XTriggerException { if (isContextOnStartupFetched()) { context = getContext(pollingNode, log); } }
public Boolean call() throws ScriptTriggerException { log.info("Running as node script"); return evaluateGroovyScript(null, scriptContent, envVars); } });
private List<Node> getPollingNodeNoPreviousBuild(XTriggerLog log) { AbstractProject project = (AbstractProject) job; Label targetLabel = getTargetLabel(log); if (targetLabel != null) { return getNodesLabel(project, targetLabel); } return null; }
private List<Node> getPollingNodeList(XTriggerLog log) { log.info("Looking nodes where the poll can be run."); List<Node> nodes; if (requiresWorkspaceForPolling()) { nodes = getPollingNodeListRequiredWS(log); } else { nodes = getPollingNodeListRequiredNoWS(log); } if (nodes == null || nodes.size() == 0) { log.info("Can't find any eligible slave nodes."); log.info("Trying to poll on master node."); nodes = Arrays.asList(getMasterNode()); } return nodes; }
@Override protected boolean checkIfModified(XTriggerLog log) throws XTriggerException { // make sure the lock is not null; when de-serialising if(lock==null){ lock = new Object(); } synchronized (lock) { C newContext = getContext(log); if (context == null) { log.info("Recording context. Check changes in next poll."); setNewContext(newContext); return false; } boolean changed = checkIfModified(context, newContext, log); return changed; } }
protected Action[] getScheduledXTriggerActions(Node pollingNode, XTriggerLog log) throws XTriggerException { Action[] actions = getScheduledActions(pollingNode, log); int nbNewAction = actions.length + 1; Action[] newActions = new Action[nbNewAction]; for (int i = 0; i < actions.length; i++) { newActions[i] = actions[i]; } try { newActions[newActions.length - 1] = new XTriggerCauseAction(FileUtils.readFileToString(getLogFile())); } catch (IOException ioe) { throw new XTriggerException(ioe); } return newActions; }
@Override public Void call() throws XTriggerException { causeAction.setBuild(build); File triggerLogFile = causeAction.getLogFile(); String logContent = causeAction.getLogMessage(); try { FileUtils.writeStringToFile(triggerLogFile, logContent); } catch (IOException ioe) { throw new XTriggerException(ioe); } return null; } });
private List<Node> candidatePollingNode(XTriggerLog log) { log.info("Looking for a candidate node to run the poll."); AbstractProject project = (AbstractProject) job; Label targetLabel = getTargetLabel(log); if (targetLabel != null) { return getNodesLabel(project, targetLabel); } else { return Jenkins.getInstance().getNodes(); } }
private List<Node> getPollingNodesWithExecutors(XTriggerLog log) { List<Node> result = new ArrayList<Node>(); List<Node> nodes = getPollingNodeList(log); for (Node node : nodes) { if (node != null && eligibleNode(node)) { result.add(node); } else if (node != null) { log.info(String.format("Finding %s but it is not eligible.", node.getDisplayName())); } } return result; }
public void initForContent(String content, XTriggerLog log) throws XTriggerException { if (content == null) { throw new XTriggerException("The given content is not set."); } if (content.trim().isEmpty()) { throw new XTriggerException("The given content is empty."); } initForContentType(content, log); }
@SuppressWarnings("unused") public String getLog() throws IOException { File logFile = getLogFile(); if (logFile == null) { return null; } return Util.loadFile(logFile); }
@SuppressWarnings("unused") public String getTitle() { if (build == null) { return "XTrigger Log"; } XTriggerCause triggerCause = (XTriggerCause) build.getCause(XTriggerCause.class); if (triggerCause == null) { return "XTrigger Log"; } return triggerCause.getTriggerName() + " Log"; }
@Override protected void doProgress() { log.info("."); }
public void log(String msg, int level) { if (msg != null && msg.length() != 0) { if (debug) { log.info(msg); } } }
@Override protected void doEndProgress(String msg) { if (msg != null && msg.length() != 0) { log.info(msg); } }
public void rawlog(String msg, int level) { if (msg != null && msg.length() != 0) { log.info(msg); } } }
private boolean checkLastModificationDate(URLTriggerEntry entry, XTriggerLog log, Date clientLastModificationDate) throws XTriggerException { boolean isTriggering = false; if (clientLastModificationDate != null) { long newLastModifiedDateTime = clientLastModificationDate.getTime(); long previousLastModificationDateTime = entry.getLastModificationDate(); if (previousLastModificationDateTime != 0 && previousLastModificationDateTime != newLastModifiedDateTime) { log.info("The last modification date has changed."); isTriggering = true; } } return isTriggering; }
@Override protected boolean checkIfModified(Node executingNode, XTriggerLog log) throws ScriptTriggerException { int expectedExitCode = getExpectedExitCode(); log.info("The expected script execution code is " + expectedExitCode); return checkIfModifiedWithScriptsEvaluation(executingNode, expectedExitCode, log); }