Skip to content

Commit

Permalink
fix(Jenkins): Skip fetch job that has not any build histories
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesin11 committed Nov 19, 2020
1 parent 16e80d3 commit 4e47425
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/runner/jenkins_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Runner } from "./runner"
import { YamlConfig } from "../config/config"
import { WorkflowReport, TestReport } from "../analyzer/analyzer"
import { CompositExporter } from "../exporter/exporter"
import { JenkinsClient } from "../client/jenkins_client"
import { BuildResponse, JenkinsClient } from "../client/jenkins_client"
import { JenkinsAnalyzer } from "../analyzer/jenkins_analyzer"
import { JenkinsConfig, JenkinsConfigJob, parseConfig } from "../config/jenkins_config"
import { LastRunStore } from "../last_run_store"
Expand Down Expand Up @@ -113,18 +113,24 @@ export class JenkinsRunner implements Runner {
const buildRespones = notConfigJobs.map((job) => {
return {
jobName: job.name,
resPromise: this.client?.fetchLastBuild(job.name)
resultPromise: this.client!.fetchLastBuild(job.name)
.then((res) => success(res))
.catch((error) => failure(error))
}
})

const stallDays = this.config.correctAllJobs.filterLastBuildDay ?? 30
const now = Date.now()
const thresholdTimestamp = now - stallDays * 24 * 60 * 60 * 1000

for (const { jobName, resPromise } of buildRespones) {
const res = await resPromise
for (const { jobName, resultPromise } of buildRespones) {
const result = await resultPromise
if (result.isFailure()) {
console.debug(`(JenkinsRunner) Skip ${jobName}: can not fetch lastBuild.`)
continue
}

if (res && res.timestamp >= thresholdTimestamp) {
if (result.isSuccess() && result.value && result.value.timestamp >= thresholdTimestamp) {
otherJobs.push({
name: jobName,
testGlob: [],
Expand Down

0 comments on commit 4e47425

Please sign in to comment.