本文整理了Java中hudson.model.Node.getWorkspaceFor()
方法的一些代码示例,展示了Node.getWorkspaceFor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getWorkspaceFor()
方法的具体详情如下:
包路径:hudson.model.Node
类名称:Node
方法名:getWorkspaceFor
[英]Returns a "workspace" directory for the given TopLevelItem.
Workspace directory is usually used for keeping out the checked out source code, but it can be used for anything.
[中]返回给定TopLevelItem的“工作区”目录。
工作区目录通常用于隐藏签出的源代码,但它可以用于任何用途。
代码示例来源:origin: jenkinsci/jenkins
FilePath ws = node.getWorkspaceFor(item);
if (ws == null) {
continue; // offline, fine
代码示例来源:origin: org.jenkins-ci.plugins/disk-usage
private boolean isContainedInWorkspace(TopLevelItem item, Node node, String path){
if(node instanceof Slave){
Slave slave = (Slave) node;
return path.contains(slave.getRemoteFS());
}
else{
if(node instanceof Jenkins){
FilePath file = Jenkins.getInstance().getWorkspaceFor(item);
return path.contains(file.getRemote());
}
else{
try{
return path.contains(node.getWorkspaceFor(item).getRemote());
}
catch(Exception e){
return false;
}
}
}
}
代码示例来源:origin: hudson.plugins/project-inheritance
public static FilePath getWorkspacePathFor(
Node n, InheritanceProject project, Map<String, String> values) {
String path = project.getParameterizedWorkspace();
if (path == null || path.isEmpty()) {
return null;
}
//Resolve the path's variables
String resolv = Resolver.resolveSingle(values, path);
if (resolv == null) { return null; }
resolv = resolv.trim();
if (resolv.isEmpty()) { return null; }
//Check if the path looks absolute; if not put it under the node
if (PathMapping.isAbsolute(resolv) == false) {
FilePath root = n.getWorkspaceFor(project);
if (root != null) {
root = root.getParent();
resolv = PathMapping.join(root.getRemote(), resolv);
}
}
return new FilePath(n.getChannel(), resolv);
}
代码示例来源:origin: org.jenkins-ci.plugins/matrix-project
protected Lease getParentWorkspaceLease(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
MatrixProject mp = getParent().getParent();
String customWorkspace = mp.getCustomWorkspace();
if (customWorkspace != null) {
final FilePath nodeRoot = n.getRootPath();
if (nodeRoot == null) {
throw new IOException("Cannot retrieve the node's root. Most probably it's offline");
}
// we allow custom workspaces to be concurrently used between jobs.
return Lease.createDummyLease(nodeRoot.child(getEnvironment(listener).expand(customWorkspace)));
}
final FilePath workspace = n.getWorkspaceFor(mp);
if (workspace == null) {
throw new IOException("Cannot retrieve the node's workspace for " + mp + ". Most probably the node is offline");
}
return wsl.allocate(workspace, getParentBuild());
}
代码示例来源:origin: i-m-c/jenkins-inheritance-plugin
FilePath root = n.getWorkspaceFor(project);
if (root != null) {
root = root.getParent();
return n.getWorkspaceFor(project);
代码示例来源:origin: jenkinsci/promoted-builds-plugin
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
if (getTarget() == null) {
throw new IOException("No Promotion target, cannot retrieve workspace");
}
String customWorkspace = Promotion.this.getProject().getCustomWorkspace();
if (customWorkspace != null) {
final FilePath rootPath = n.getRootPath();
if (rootPath == null) {
throw new IOException("Cannot retrieve the root path of the node " + n);
}
// we allow custom workspaces to be concurrently used between jobs.
return Lease.createDummyLease(
rootPath.child(getEnvironment(listener).expand(customWorkspace)));
}
TopLevelItem item = (TopLevelItem)getTarget().getProject();
FilePath workspace = n.getWorkspaceFor(item);
if (workspace == null) {
throw new IOException("Cannot retrieve workspace for " + item + " on the node " + n);
}
return wsl.allocate(workspace, promotionRun);
}
代码示例来源:origin: org.jenkins-ci.plugins/disk-usage
FilePath path =null;
try{
path = node.getWorkspaceFor((TopLevelItem)owner);
if(path!=null && path.exists() && (diskUsage.slaveWorkspacesUsage.get(node.getNodeName())==null || !diskUsage.slaveWorkspacesUsage.get(node.getNodeName()).containsKey(path.getRemote()))){
putSlaveWorkspace(node, path.getRemote());
代码示例来源:origin: org.jenkins-ci.plugins/disk-usage
public Object readResolve() {
//for keeping backward compatibility
if(diskUsage!=null){
buildDiskUsage = diskUsage.buildUsage;
Node node = build.getBuiltOn();
if(node!=null && diskUsage.wsUsage!=null && diskUsage.wsUsage > 0){
DiskUsageProperty property = (DiskUsageProperty) build.getProject().getProperty(DiskUsageProperty.class);
AbstractProject project = build.getProject().getRootProject();
if(property!=null && (project instanceof TopLevelItem))
property.putSlaveWorkspaceSize(node, node.getWorkspaceFor((TopLevelItem)project).getRemote(), diskUsage.wsUsage);
}
diskUsage=null;
}
return this;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
FilePath ws = node.getWorkspaceFor(item);
if (ws == null) {
continue; // offline, fine
代码示例来源:origin: jenkinsci/docker-slaves-plugin
throw new Exception(j + " must be a top-level job");
FilePath p = node.getWorkspaceFor((TopLevelItem) j);
if (p == null) {
throw new IllegalStateException(node + " is offline");
代码示例来源:origin: groupon/DotCi
protected Lease getParentWorkspaceLease(final Node n, final WorkspaceList wsl) throws InterruptedException, IOException {
final DynamicProject mp = getParent().getParent();
final String customWorkspace = mp.getCustomWorkspace();
if (customWorkspace != null) {
// we allow custom workspaces to be concurrently used between
// jobs.
return Lease.createDummyLease(n.getRootPath().child(getEnvironment(this.listener).expand(customWorkspace)));
}
return wsl.allocate(n.getWorkspaceFor(mp), getParentBuild());
}
代码示例来源:origin: io.jenkins.plugins/docker-slaves
throw new Exception(j + " must be a top-level job");
FilePath p = node.getWorkspaceFor((TopLevelItem) j);
if (p == null) {
throw new IllegalStateException(node + " is offline");
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step
throw new Exception(j + " must be a top-level job");
FilePath p = node.getWorkspaceFor((TopLevelItem) j);
if (p == null) {
throw new IllegalStateException(node + " is offline");
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-cps-global-lib
static void doRetrieve(String name, boolean changelog, @Nonnull SCM scm, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception {
// Adapted from CpsScmFlowDefinition:
SCMStep delegate = new GenericSCMStep(scm);
delegate.setPoll(false); // TODO we have no API for determining if a given SCMHead is branch-like or tag-like; would we want to turn on polling if the former?
delegate.setChangelog(changelog);
FilePath dir;
Node node = Jenkins.getActiveInstance();
if (run.getParent() instanceof TopLevelItem) {
FilePath baseWorkspace = node.getWorkspaceFor((TopLevelItem) run.getParent());
if (baseWorkspace == null) {
throw new IOException(node.getDisplayName() + " may be offline");
}
dir = baseWorkspace.withSuffix(getFilePathSuffix() + "libs").child(name);
} else { // should not happen, but just in case:
throw new AbortException("Cannot check out in non-top-level build");
}
Computer computer = node.toComputer();
if (computer == null) {
throw new IOException(node.getDisplayName() + " may be offline");
}
try (WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(dir)) {
delegate.checkout(run, lease.path, listener, node.createLauncher(listener));
// Cannot add WorkspaceActionImpl to private CpsFlowExecution.flowStartNodeActions; do we care?
// Copy sources with relevant files from the checkout:
lease.path.copyRecursiveTo("src/**/*.groovy,vars/*.groovy,vars/*.txt,resources/", null, target);
}
}
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step
FilePath baseWorkspace = node.getWorkspaceFor((TopLevelItem) job);
if (baseWorkspace == null) {
throw new IllegalStateException(node + " is offline");
代码示例来源:origin: jenkinsci/workflow-cps-plugin
Node node = Jenkins.get();
if (build.getParent() instanceof TopLevelItem) {
FilePath baseWorkspace = node.getWorkspaceFor((TopLevelItem) build.getParent());
if (baseWorkspace == null) {
throw new IOException(node.getDisplayName() + " may be offline");
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
// Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'.
String subtree;
if(useShortWorkspaceName) {
subtree = getParent().getDigestName();
} else {
subtree = getParent().getCombination().toString('/','/', true);
}
String customWorkspace = getParent().getParent().getCustomWorkspace();
if (customWorkspace != null) {
// Use custom workspace as defined in the matrix project settings.
FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace));
// We allow custom workspaces to be used concurrently between jobs.
return Lease.createDummyLease(ws.child(subtree));
} else {
// Use default workspace as assigned by Hudson.
Node node = getBuiltOn();
FilePath ws = node.getWorkspaceFor(getParent().getParent());
// Allocate unique workspace (not to be shared between jobs and runs).
return wsl.allocate(ws.child(subtree));
}
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
// Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'.
String subtree;
if (useShortWorkspaceName) {
subtree = getParent().getDigestName();
} else {
subtree = getParent().getCombination().toString('/', '/', true);
}
String customWorkspace = getParent().getParent().getCustomWorkspace();
if (customWorkspace != null) {
// Use custom workspace as defined in the matrix project settings.
FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace));
// We allow custom workspaces to be used concurrently between jobs.
return Lease.createDummyLease(ws.child(subtree));
} else {
// Use default workspace as assigned by Hudson.
Node node = getBuiltOn();
FilePath ws = node.getWorkspaceFor(getParent().getParent());
// Allocate unique workspace (not to be shared between jobs and runs).
return wsl.allocate(ws.child(subtree));
}
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
// Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'.
String subtree;
if(useShortWorkspaceName) {
subtree = getParent().getDigestName();
} else {
subtree = getParent().getCombination().toString('/','/', true);
}
String customWorkspace = getParent().getParent().getCustomWorkspace();
if (customWorkspace != null) {
// Use custom workspace as defined in the matrix project settings.
FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace));
// We allow custom workspaces to be used concurrently between jobs.
return Lease.createDummyLease(ws.child(subtree));
} else {
// Use default workspace as assigned by Hudson.
Node node = getBuiltOn();
FilePath ws = node.getWorkspaceFor(getParent().getParent());
// Allocate unique workspace (not to be shared between jobs and runs).
return wsl.allocate(ws.child(subtree));
}
}
}
代码示例来源:origin: hudson/hudson-2.x
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
// Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'.
String subtree;
if(useShortWorkspaceName) {
subtree = getParent().getDigestName();
} else {
subtree = getParent().getCombination().toString('/','/', true);
}
String customWorkspace = getParent().getParent().getCustomWorkspace();
if (customWorkspace != null) {
// Use custom workspace as defined in the matrix project settings.
FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace));
// We allow custom workspaces to be used concurrently between jobs.
return Lease.createDummyLease(ws.child(subtree));
} else {
// Use default workspace as assigned by Hudson.
Node node = getBuiltOn();
FilePath ws = node.getWorkspaceFor(getParent().getParent());
// Allocate unique workspace (not to be shared between jobs and runs).
return wsl.allocate(ws.child(subtree));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!