Java Code Examples for hudson.model.Run#getRootDir()

The following examples show how to use hudson.model.Run#getRootDir() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhabricatorNotifier.java    From phabricator-jenkins-plugin with MIT License 6 votes vote down vote up
private void copyCoverageToJenkinsMaster(Run<?, ?> build, FilePath workspace, TaskListener listener) {
    Logger logger = new Logger(listener.getLogger());
    final File buildDir = build.getRootDir();
    FilePath buildTarget = new FilePath(buildDir);

    String finalCoverageReportPattern = coverageReportPattern != null ? coverageReportPattern :
            DEFAULT_XML_COVERAGE_REPORT_PATTERN;

    if (workspace != null) {
        try {
            int i = 0;
            for (FilePath report : workspace.list(finalCoverageReportPattern)) {
                final FilePath targetPath = new FilePath(buildTarget, PHABRICATOR_COVERAGE + (i == 0 ? "" : i) + ".xml");
                report.copyTo(targetPath);
                i++;
            }
        } catch (InterruptedException | IOException e) {
            e.printStackTrace();
            logger.warn(COVERAGE_TAG, "Unable to copy coverage to " + buildTarget);
        }
    }
}
 
Example 2
Source File: LastSuccessfulBuildStrategy.java    From semantic-versioning-plugin with MIT License 6 votes vote down vote up
public String getDisplayString(Job job) {
    String semanticVersion = null;
    Run run = job.getLastSuccessfulBuild();
    if (run == null) {
        logger.info("LastSuccessfulBuildStrategy::getDisplayString -> last successful build not found.");
        semanticVersion = Messages.UNKNOWN_VERSION;
    } else {
        String filename = run.getRootDir() + "/" + Messages.SEMANTIC_VERSION_FILENAME;
        logger.info("LastSuccessfulBuildStrategy::getDisplayString -> last successful build found. Filename -> " + filename);
        File file = new File(filename);
        if (file.exists()) {
            try {
                semanticVersion = FileUtils.readFileToString(file);
                logger.info("LastSuccessfulBuildStrategy::getDisplayString -> read semantic version from file -> " + semanticVersion);
            } catch (IOException e) {
                logger.severe(e.toString());
            }
        } else {
            logger.info("LastSuccessfulBuildStrategy::getDisplayString -> semanticVersion file not found.");
            semanticVersion = Messages.UNKNOWN_VERSION;
        }
    }

    return semanticVersion;
}
 
Example 3
Source File: IssuesRecorder.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
private AnnotatedReport scanWithTool(final Run<?, ?> run, final FilePath workspace, final TaskListener listener,
        final Tool tool) throws IOException, InterruptedException {
    IssuesScanner issuesScanner = new IssuesScanner(tool, getFilters(), getSourceCodeCharset(),
            workspace, sourceDirectory, run,
            new FilePath(run.getRootDir()), listener, isBlameDisabled ? BlameMode.DISABLED : BlameMode.ENABLED,
            isForensicsDisabled ? ForensicsMode.DISABLED : ForensicsMode.ENABLED);

    return issuesScanner.scan();
}
 
Example 4
Source File: CukedoctorPublisher.java    From cucumber-living-documentation-plugin with MIT License 5 votes vote down vote up
/**
 * mainly for findbugs be happy
 *
 * @param build
 * @return
 */
private FilePath getMasterWorkspaceDir(Run<?, ?> build) {
    if (build != null && build.getRootDir() != null) {
        return new FilePath(build.getRootDir());
    } else {
        return new FilePath(Paths.get("").toFile());
    }
}