hudson.Functions.isWipeOutPermissionEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(90)

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

Functions.isWipeOutPermissionEnabled介绍

[英]Returns true if the Item#WIPEOUT permission is enabled. By default the "Wipe Out Workspace" action is available on job when user has Item#BUILD permission (if user can trigger builds). If this behavior is not acceptable for project you can enable the hudson.security.WipeOutPermission system property. It will add "WipeOut" permission checkbox into permission control panel to manage "Wipe Out Workspace" action.
[中]如果项目#清除权限已启用,则返回true。默认情况下,当用户具有项目#生成权限(如果用户可以触发生成)时,“擦除工作区”操作在作业上可用。如果此行为不适用于项目,则可以启用hudson。安全WipeOutPermission系统属性。它会将“清除”权限复选框添加到权限控制面板中,以管理“清除工作区”操作。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Wipes out the workspace.
 */
@RequirePOST
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
  checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
  R b = getSomeBuildWithWorkspace();
  FilePath ws = b!=null ? b.getWorkspace() : null;
  if (ws!=null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
    ws.deleteRecursive();
    for (WorkspaceListener wl : WorkspaceListener.all()) {
      wl.afterDelete(this);
    }
    return new HttpRedirect(".");
  } else {
    // If we get here, that means the SCM blocked the workspace deletion.
    return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly");
  }
}

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

/**
 * Wipes out the workspace.
 */
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
  checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
  try {
    if (cleanWorkspace()) {
      return new HttpRedirect(".");
    } else {
      return new ForwardToView(this, "wipeOutWorkspaceBlocked.jelly");
    }
  } catch (final IOException e) {
    ForwardToView resp = new ForwardToView(this, "error.jelly") {
      @Override
      public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
        req.setAttribute("message", Messages._AbstractProject_UnableWipeOut());
        req.setAttribute("pre", false);
        req.setAttribute("exception", e);
        super.generateResponse(req, rsp, node);
      }
    };
    return resp;
  }
}

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

/**
 * Wipes out the workspace.
 */
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
  checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
  try {
    if (cleanWorkspace()) {
      return new HttpRedirect(".");
    } else {
      return new ForwardToView(this, "wipeOutWorkspaceBlocked.jelly");
    }
  } catch (final IOException e) {
    ForwardToView resp = new ForwardToView(this, "error.jelly") {
      @Override
      public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
        req.setAttribute("message", Messages._AbstractProject_UnableWipeOut());
        req.setAttribute("pre", false);
        req.setAttribute("exception", e);
        super.generateResponse(req, rsp, node);
      }
    };
    return resp;
  }
}

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

/**
 * Wipes out the workspace.
 */
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
  checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
  try {
    if (cleanWorkspace()) {
      return new HttpRedirect(".");
    } else {
      return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly");
    }
  } catch (IOException e) {
    ForwardToView resp = new ForwardToView(this, "error.jelly");
    resp.with("message", Messages._AbstractProject_UnableWipeOut());
    resp.with("pre", false);
    resp.with("exception", e);
    return resp;
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Wipes out the workspace.
 */
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
  checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
  try {
    if (cleanWorkspace()) {
      return new HttpRedirect(".");
    } else {
      return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly");
    }
  } catch (IOException e) {
    ForwardToView resp = new ForwardToView(this, "error.jelly");
    resp.with("message", Messages._AbstractProject_UnableWipeOut());
    resp.with("pre", false);
    resp.with("exception", e);
    return resp;
  }
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Wipes out the workspace.
 */
@RequirePOST
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
  checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
  R b = getSomeBuildWithWorkspace();
  FilePath ws = b!=null ? b.getWorkspace() : null;
  if (ws!=null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
    ws.deleteRecursive();
    for (WorkspaceListener wl : WorkspaceListener.all()) {
      wl.afterDelete(this);
    }
    return new HttpRedirect(".");
  } else {
    // If we get here, that means the SCM blocked the workspace deletion.
    return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly");
  }
}

相关文章

微信公众号

最新文章

更多