hudson.model.Hudson.getScriptSupport()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中hudson.model.Hudson.getScriptSupport()方法的一些代码示例,展示了Hudson.getScriptSupport()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hudson.getScriptSupport()方法的具体详情如下:
包路径:hudson.model.Hudson
类名称:Hudson
方法名:getScriptSupport

Hudson.getScriptSupport介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Evaluates the given Dynamic Language Script Expression  with values bound from this combination.
 * <p>
 * For example, if this combination is a=X,b=Y, then expressions like <tt>a=="X"</tt> would evaluate to
 * true.
 * @param axes
 * @param expression
 * @param scriptType
 * @return 
 */
public boolean evalScriptExpression(AxisList axes, String expression) {
  if (Util.fixEmptyAndTrim(expression) == null) {
    return true;
  }
  Object result = Boolean.TRUE;
  if (Hudson.getInstance().getScriptSupport() != null) {
    expression = "use(" + BooleanCategory.class.getName().replace('$', '.') + ") {" + expression + "}";
    Map<String, Object> variableMap = new HashMap<String, Object>();
    for (Map.Entry<String, String> e : entrySet()) {
      variableMap.put(e.getKey(), e.getValue());
    }
    variableMap.put("index", toModuloIndex(axes));
    variableMap.put("uniqueId", toIndex(axes));
    result = Hudson.getInstance().getScriptSupport().evaluateExpression(expression, variableMap);
  }
  return TRUE.equals(result);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Evaluates the given Dynamic Language Script Expression with values bound
 * from this combination. <p> For example, if this combination is a=X,b=Y,
 * then expressions like <tt>a=="X"</tt> would evaluate to true.
 *
 * @param axes
 * @param expression
 * @param scriptType
 * @return
 */
public boolean evalScriptExpression(AxisList axes, String expression) {
  if (Util.fixEmptyAndTrim(expression) == null) {
    return true;
  }
  Object result = Boolean.TRUE;
  if (Hudson.getInstance().getScriptSupport() != null) {
    expression = "use(" + BooleanCategory.class.getName().replace('$', '.') + ") {" + expression + "}";
    Map<String, Object> variableMap = new HashMap<String, Object>();
    for (Map.Entry<String, String> e : entrySet()) {
      variableMap.put(e.getKey(), e.getValue());
    }
    variableMap.put("index", toModuloIndex(axes));
    variableMap.put("uniqueId", toIndex(axes));
    result = Hudson.getInstance().getScriptSupport().evaluateExpression(expression, variableMap);
  }
  return TRUE.equals(result);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

protected void _doScript( StaplerRequest req, StaplerResponse rsp, String view) throws IOException, ServletException {
  // ability to run arbitrary script is dangerous,
  // so tie it to the admin access
  checkPermission(Hudson.ADMINISTER);
  if (Hudson.getInstance().getScriptSupport() != null) {
    String text = req.getParameter("script");
    if (text != null) {
      try {
        req.setAttribute("output",
            RemotingDiagnostics.executeScript(text, getChannel(), Hudson.getInstance().getScriptSupport()));
      } catch (InterruptedException e) {
        throw new ServletException(e);
      }
    }
  }
  req.getView(this,view).forward(req,rsp);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

protected void _doScript(StaplerRequest req, StaplerResponse rsp, String view) throws IOException, ServletException {
  // ability to run arbitrary script is dangerous,
  // so tie it to the admin access
  checkPermission(Hudson.ADMINISTER);
  if (Hudson.getInstance().getScriptSupport() != null) {
    String text = req.getParameter("script");
    if (text != null) {
      if (!"POST".equals(req.getMethod())) {
        throw HttpResponses.error(HttpURLConnection.HTTP_BAD_METHOD, "requires POST");
      }
      try {
        if (getChannel() == null){
           rsp.getWriter().println("Failed to run the script. Is node online?");
           return;
        }
        req.setAttribute("output",
            RemotingDiagnostics.executeScript(text, getChannel(), Hudson.getInstance().getScriptSupport()));
      } catch (InterruptedException e) {
        throw new ServletException(e);
      }
    }
  }
  req.getView(this, view).forward(req, rsp);
}

相关文章

微信公众号

最新文章

更多

Hudson类方法