jenkins.model.Jenkins.getRawBuildsDir()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(101)

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

Jenkins.getRawBuildsDir介绍

暂无

代码示例

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

@Override
  public void onLocationChanged(Item item, String oldFullName, String newFullName) {
    final Jenkins jenkins = Jenkins.getInstance();
    if (!jenkins.isDefaultBuildDir() && item instanceof Job) {
      File newBuildDir = ((Job)item).getBuildDir();
      try {
        if (!Util.isDescendant(item.getRootDir(), newBuildDir)) {
          //OK builds are stored somewhere outside of the item's root, so none of the other move operations has probably moved it.
          //So let's try even though we lack some information
          String oldBuildsDir = Jenkins.expandVariablesForDirectory(jenkins.getRawBuildsDir(), oldFullName, "<NOPE>");
          if (oldBuildsDir.contains("<NOPE>")) {
            LOGGER.severe(String.format("Builds directory for job %1$s appears to be outside of item root," +
                " but somehow still containing the item root path, which is unknown. Cannot move builds from %2$s to %1$s.", newFullName, oldFullName));
          } else {
            File oldDir = new File(oldBuildsDir);
            if (oldDir.isDirectory()) {
              try {
                FileUtils.moveDirectory(oldDir, newBuildDir);
              } catch (IOException e) {
                LOGGER.log(Level.SEVERE, String.format("Failed to move %s to %s", oldBuildsDir, newBuildDir.getAbsolutePath()), e);
              }
            }
          }
        }
      } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Failed to inspect " + item.getRootDir() + ". Builds might not be moved.", e);
      }
    }
  }
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

@Test
@ConfiguredWithCode(value = "SelfConfiguratorTest.yml")
public void self_configure() {
  assertEquals("/tmp", Jenkins.getInstance().getRawBuildsDir());
}

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

@Override
  public void onLocationChanged(Item item, String oldFullName, String newFullName) {
    final Jenkins jenkins = Jenkins.getInstance();
    if (!jenkins.isDefaultBuildDir() && item instanceof Job) {
      File newBuildDir = ((Job)item).getBuildDir();
      try {
        if (!Util.isDescendant(item.getRootDir(), newBuildDir)) {
          //OK builds are stored somewhere outside of the item's root, so none of the other move operations has probably moved it.
          //So let's try even though we lack some information
          String oldBuildsDir = Jenkins.expandVariablesForDirectory(jenkins.getRawBuildsDir(), oldFullName, "<NOPE>");
          if (oldBuildsDir.contains("<NOPE>")) {
            LOGGER.severe(String.format("Builds directory for job %1$s appears to be outside of item root," +
                " but somehow still containing the item root path, which is unknown. Cannot move builds from %2$s to %1$s.", newFullName, oldFullName));
          } else {
            File oldDir = new File(oldBuildsDir);
            if (oldDir.isDirectory()) {
              try {
                FileUtils.moveDirectory(oldDir, newBuildDir);
              } catch (IOException e) {
                LOGGER.log(Level.SEVERE, String.format("Failed to move %s to %s", oldBuildsDir, newBuildDir.getAbsolutePath()), e);
              }
            }
          }
        }
      } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Failed to inspect " + item.getRootDir() + ". Builds might not be moved.", e);
      }
    }
  }
}

相关文章

微信公众号

最新文章

更多

Jenkins类方法