hudson.model.AbstractBuild.getModuleRoot()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(82)

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

AbstractBuild.getModuleRoot介绍

[英]Returns the root directory of the checked-out module.

This is usually where pom.xml, build.xml and so on exists.
[中]返回签出模块的根目录。
这通常是pom的位置。xml,构建。xml等等都存在。

代码示例

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

/**
 * Returns the root directory of the checked-out module.
 * <p>
 * This is usually where {@code pom.xml}, {@code build.xml}
 * and so on exists.
 *
 * @deprecated as of 1.319
 *      See {@link #getWorkspace()} for a migration strategy.
 */
@Deprecated
public FilePath getModuleRoot() {
  AbstractBuild b = getBuildForDeprecatedMethods();
  return b != null ? b.getModuleRoot() : null;
}

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

@Override
public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) {
  if (StringUtils.isEmpty(path)) {
    return null;
  }
  try {
    EnvVars env = build.getEnvironment(listener);
    String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver());
    targetPath = env.expand(targetPath);
    if (IOUtils.isAbsolute(targetPath)) {
      return new FilePath(new File(targetPath));
    } else {
      FilePath mrSettings = build.getModuleRoot().child(targetPath);
      FilePath wsSettings = build.getWorkspace().child(targetPath);
      try {
        if (!wsSettings.exists() && mrSettings.exists()) {
          wsSettings = mrSettings;
        }
      } catch (Exception e) {
        throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote());
      }
      return wsSettings;
    }
  } catch (Exception e) {
    throw new IllegalStateException("failed to prepare global settings.xml");
  }
}

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

@Override
public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) {
  if (StringUtils.isEmpty(path)) {
    return null;
  }
  try {
    EnvVars env = build.getEnvironment(listener);
    String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver());
    targetPath = env.expand(targetPath);
    if (IOUtils.isAbsolute(targetPath)) {
      return new FilePath(new File(targetPath));
    } else {
      FilePath mrSettings = build.getModuleRoot().child(targetPath);
      FilePath wsSettings = build.getWorkspace().child(targetPath);
      try {
        if (!wsSettings.exists() && mrSettings.exists()) {
          wsSettings = mrSettings;
        }
      } catch (Exception e) {
        throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote());
      }
      return wsSettings;
    }
  } catch (Exception e) {
    throw new IllegalStateException("failed to prepare settings.xml");
  }
}

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

int r = launcher.launch().cmds(args).envs(env).stdout(mca).pwd(build.getModuleRoot()).join();
if (0 != r) {
  return false;

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

/**
 * Returns the root directory of the checked-out module. <p> This is usually
 * where <tt>pom.xml</tt>, <tt>build.xml</tt> and so on exists.
 *
 * @deprecated as of 1.319 See {@link #getWorkspace()} for a migration
 * strategy.
 */
public FilePath getModuleRoot() {
  AbstractBuild b = getBuildForDeprecatedMethods();
  return b != null ? b.getModuleRoot() : null;
}

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

/**
 * Returns the root directory of the checked-out module. <p> This is usually
 * where <tt>pom.xml</tt>, <tt>build.xml</tt> and so on exists.
 *
 * @deprecated as of 1.319 See {@link #getWorkspace()} for a migration
 * strategy.
 */
public FilePath getModuleRoot() {
  AbstractBuild b = getBuildForDeprecatedMethods();
  return b != null ? b.getModuleRoot() : null;
}

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

/**
 * Returns the root directory of the checked-out module.
 * <p>
 * This is usually where <tt>pom.xml</tt>, <tt>build.xml</tt>
 * and so on exists.
 *
 * @deprecated as of 1.319
 *      See {@link #getWorkspace()} for a migration strategy.
 */
public FilePath getModuleRoot() {
  AbstractBuild b = getBuildForDeprecatedMethods();
  return b != null ? b.getModuleRoot() : null;
}

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

/**
 * Returns the root directory of the checked-out module.
 * <p>
 * This is usually where <tt>pom.xml</tt>, <tt>build.xml</tt>
 * and so on exists.
 *
 * @deprecated as of 1.319
 *      See {@link #getWorkspace()} for a migration strategy.
 */
public FilePath getModuleRoot() {
  AbstractBuild b = getBuildForDeprecatedMethods();
  return b != null ? b.getModuleRoot() : null;
}

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

/**
 * Returns the root directory of the checked-out module.
 * <p>
 * This is usually where <tt>pom.xml</tt>, <tt>build.xml</tt>
 * and so on exists.
 *
 * @deprecated as of 1.319
 *      See {@link #getWorkspace()} for a migration strategy.
 */
@Deprecated
public FilePath getModuleRoot() {
  AbstractBuild b = getBuildForDeprecatedMethods();
  return b != null ? b.getModuleRoot() : null;
}

代码示例来源:origin: jenkinsci/gradle-plugin

private FilePath getNormalizedRootBuildScriptDir(AbstractBuild<?, ?> build, VariableResolver<String> resolver) {
  FilePath normalizedRootBuildScriptDir = null;
  if (rootBuildScriptDir != null && rootBuildScriptDir.trim().length() != 0) {
    String rootBuildScriptNormalized = replaceWhitespaceBySpace(rootBuildScriptDir.trim());
    rootBuildScriptNormalized = Util.replaceMacro(rootBuildScriptNormalized.trim(), resolver);
    normalizedRootBuildScriptDir = new FilePath(build.getModuleRoot(), rootBuildScriptNormalized);
  }
  return normalizedRootBuildScriptDir;
}

代码示例来源:origin: jenkinsci/artifactory-plugin

private String getMavenProjectPath(Run<?, ?> build, FilePath ws) {
  if (build instanceof AbstractBuild) {
    if (StringUtils.isNotBlank(getRootPom())) {
      return ((AbstractBuild) build).getModuleRoot().getRemote() + File.separatorChar +
          getRootPom().replace("/pom.xml", StringUtils.EMPTY);
    }
    return ((AbstractBuild) build).getModuleRoot().getRemote();
  }
  return ws.getRemote();
}

代码示例来源:origin: jenkinsci/gradle-plugin

private List<FilePath> getPossibleWrapperLocations(AbstractBuild<?, ?> build, Launcher launcher, VariableResolver<String> resolver, FilePath normalizedRootBuildScriptDir) throws IOException, InterruptedException {
  FilePath moduleRoot = build.getModuleRoot();
  if (wrapperLocation != null && wrapperLocation.trim().length() != 0) {
    // Override with provided relative path to gradlew
    String wrapperLocationNormalized = wrapperLocation.trim().replaceAll("[\t\r\n]+", "");
    wrapperLocationNormalized = Util.replaceMacro(wrapperLocationNormalized.trim(), resolver);
    return ImmutableList.of(new FilePath(moduleRoot, wrapperLocationNormalized));
  } else if (buildFile != null && !buildFile.isEmpty()) {
    // Check if the target project is located not at the root dir
    FilePath parentOfBuildFile = new FilePath(normalizedRootBuildScriptDir == null ? moduleRoot : normalizedRootBuildScriptDir, buildFile).getParent();
    if (parentOfBuildFile != null && !parentOfBuildFile.equals(moduleRoot)) {
      return ImmutableList.of(parentOfBuildFile, moduleRoot);
    }
  }
  return ImmutableList.of(moduleRoot);
}

代码示例来源:origin: org.jenkins-ci.plugins/gradle

private List<FilePath> getPossibleWrapperLocations(AbstractBuild<?, ?> build, Launcher launcher, EnvVars env, FilePath normalizedRootBuildScriptDir) throws IOException, InterruptedException {
  FilePath moduleRoot = build.getModuleRoot();
  if (wrapperLocation != null && wrapperLocation.trim().length() != 0) {
    // Override with provided relative path to gradlew
    String wrapperLocationNormalized = wrapperLocation.trim().replaceAll("[\t\r\n]+", "");
    wrapperLocationNormalized = Util.replaceMacro(wrapperLocationNormalized.trim(), env);
    wrapperLocationNormalized = Util.replaceMacro(wrapperLocationNormalized, build.getBuildVariableResolver());
    return ImmutableList.of(new FilePath(moduleRoot, wrapperLocationNormalized));
  } else if (buildFile != null && !buildFile.isEmpty()) {
    // Check if the target project is located not at the root dir
    char fileSeparator = launcher.isUnix() ? '/' : '\\';
    int i = buildFile.lastIndexOf(fileSeparator);
    if (i > 0) {
      // Check if there is a wrapper script at the target project's dir.
      FilePath candidate = new FilePath(normalizedRootBuildScriptDir == null ? moduleRoot : normalizedRootBuildScriptDir, buildFile.substring(0, i));
      return ImmutableList.of(candidate, moduleRoot);
    }
  }
  return ImmutableList.of(moduleRoot);
}

代码示例来源:origin: SonarSource/sonar-scanner-jenkins

public static FilePath getModuleRoot(Run<?, ?> run, FilePath workspace) {
  FilePath moduleRoot = null;

  if (run instanceof AbstractBuild) {
   AbstractBuild<?, ?> build = (AbstractBuild<?, ?>) run;
   moduleRoot = build.getModuleRoot();
  } else {
   // otherwise get the first module of the first SCM
   Object parent = run.getParent();
   if (parent instanceof SCMTriggerItem) {
    SCMTriggerItem scmTrigger = (SCMTriggerItem) parent;
    Collection<? extends SCM> scms = scmTrigger.getSCMs();
    if (!scms.isEmpty()) {
     SCM scm = scms.iterator().next();
     FilePath[] moduleRoots = scm.getModuleRoots(workspace, null);
     moduleRoot = moduleRoots != null && moduleRoots.length > 0 ? moduleRoots[0] : null;
    }
   }
   if (moduleRoot == null) {
    moduleRoot = workspace;
   }
  }
  return moduleRoot;
 }
}

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

@Override
public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) {
  if (StringUtils.isEmpty(path)) {
    return null;
  }
  try {
    EnvVars env = build.getEnvironment(listener);
    String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver());
    targetPath = env.expand(targetPath);
    if (IOUtils.isAbsolute(targetPath)) {
      return new FilePath(new File(targetPath));
    } else {
      FilePath mrSettings = build.getModuleRoot().child(targetPath);
      FilePath wsSettings = build.getWorkspace().child(targetPath);
      try {
        if (!wsSettings.exists() && mrSettings.exists()) {
          wsSettings = mrSettings;
        }
      } catch (Exception e) {
        throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote());
      }
      return wsSettings;
    }
  } catch (Exception e) {
    throw new IllegalStateException("failed to prepare settings.xml");
  }
}

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

@Override
public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) {
  if (StringUtils.isEmpty(path)) {
    return null;
  }
  try {
    EnvVars env = build.getEnvironment(listener);
    String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver());
    targetPath = env.expand(targetPath);
    if (IOUtils.isAbsolute(targetPath)) {
      return new FilePath(new File(targetPath));
    } else {
      FilePath mrSettings = build.getModuleRoot().child(targetPath);
      FilePath wsSettings = build.getWorkspace().child(targetPath);
      try {
        if (!wsSettings.exists() && mrSettings.exists()) {
          wsSettings = mrSettings;
        }
      } catch (Exception e) {
        throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote());
      }
      return wsSettings;
    }
  } catch (Exception e) {
    throw new IllegalStateException("failed to prepare global settings.xml");
  }
}

代码示例来源:origin: lacostej/jenkins-unity3d-plugin

private ArgumentListBuilder prepareCommandlineArguments(AbstractBuild<?,?> build, Launcher launcher, Unity3dInstallation ui, EnvVars vars) throws IOException, InterruptedException, PerformException {
  String exe = ui.getExecutable(launcher);
  if (exe==null) {
    throw new PerformException(Messages.Unity3d_ExecutableNotFound(ui.getName()));
  }
  FilePath moduleRoot = build.getModuleRoot();
  String moduleRootRemote = moduleRoot.getRemote();
  Map<String,String> buildParameters = build.getBuildVariables();
  return createCommandlineArgs(exe, moduleRootRemote, vars, buildParameters);
}

代码示例来源:origin: jenkinsci/sbt-plugin

FilePath workDir = build.getModuleRoot();
try {

代码示例来源:origin: jenkinsci/artifactory-plugin

@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
    throws InterruptedException, IOException {
  listener.getLogger().println("Jenkins Artifactory Plugin version: " + ActionableHelper.getArtifactoryPluginVersion());
  EnvVars env = build.getEnvironment(listener);
  FilePath workDir = build.getModuleRoot();
  FilePath ws = build.getWorkspace();
  FilePath mavenHome = getMavenHome(listener, env, launcher);
  if (!mavenHome.exists()) {
    listener.error("Couldn't find Maven home: " + mavenHome.getRemote());
    throw new Run.RunnerAbortedException();
  }
  ArgumentListBuilder cmdLine = buildMavenCmdLine(build, listener, env, launcher, mavenHome, ws, ws);
  String[] cmds = cmdLine.toCommandArray();
  return RunMaven(build, launcher, listener, env, workDir, cmds);
}

代码示例来源:origin: org.jvnet.hudson.plugins/testng-plugin

new FilePath(build.getProject().getRootDir()),
  new FilePath(build.getRootDir()),
  build.getModuleRoot(),
  build.getTimestamp());
|| masterGhostwriter.performFromMaster(build, build.getModuleRoot(), listener);

相关文章

微信公众号

最新文章

更多

AbstractBuild类方法