fun tryFindWorkspace()

in plugin-bazel-agent/src/main/kotlin/jetbrains/buildServer/bazel/WorkspaceExplorer.kt [15:30]


    fun tryFindWorkspace(path: File): Workspace? {
        val commandLine = _commandLineBuilder.build(_infoWorkspaceCommand)
        val result = _commandLineExecutor.tryExecute(commandLine)
        if (result.exitCode == 0) {
            try {
                val workspace = Workspace(File(result.stdOut.trim()), _commandLineBuilder.build(_fullCleanCommand))
                LOG.info("The workspace \"${workspace.path}\" was found for \"$path\"")
                return workspace
            } catch (ex: Exception) {
                LOG.error("Cannot find a workspace for \"$path\".", ex)
            }
        }

        LOG.warn("The workspace \"${BazelConstants.WORKSPACE_FILE_NAME}\" was not found for \"$path\"")
        return null
    }