Fix an undefined latestRun exception
What type of PR is this?
/kind bug /area devops
What this PR does / why we need it:
Because DevOps backend won't execute for git tag of multi branch Pipeline automatically. So branch detail may not contain latestRun
field, like as below:
{
"items": [
{
"name": "sonarqube",
"latestRun": {
"causes": [
{
"shortDescription": "Branch indexing"
}
],
"endTime": "2021-10-20T06:51:25Z",
"startTime": "2021-10-20T06:48:14Z",
"id": "1",
"pipeline": "sonarqube",
"result": "FAILURE",
"state": "FINISHED"
},
"branch": {
"url": "https://github.com/JohnNiang/devops-java-thin-sample/tree/sonarqube"
}
},
{
"name": "v0.0.1",
"weatherScore": 100,
"branch": {
"url": "https://github.com/JohnNiang/devops-java-thin-sample/tree/v0.0.1"
}
}
],
"totalItems": 4
}
This data structure would lead to an error as follow:
7.5a100bedc09c8d76e15a.js:1
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'startTime')
at Object.render (7.5a100bedc09c8d76e15a.js:1)
at Fn (main.078db83f5615ed9ea0d3.js:28)
at qa (main.078db83f5615ed9ea0d3.js:86)
at ml (main.078db83f5615ed9ea0d3.js:86)
at cu (main.078db83f5615ed9ea0d3.js:86)
at lu (main.078db83f5615ed9ea0d3.js:86)
at Zl (main.078db83f5615ed9ea0d3.js:86)
at main.078db83f5615ed9ea0d3.js:86
at t.unstable_runWithPriority (main.078db83f5615ed9ea0d3.js:94)
at Vo (main.078db83f5615ed9ea0d3.js:86)
This PR tries to mute this error.
Which issue(s) this PR fixes:
None
Special notes for reviewers:
Steps to test
Docker image for test: johnniang/ks-console:bug-blank-branch-page-dev
- Create a GitHub Pipeline with repository https://github.com/JohnNiang/devops-java-thin-sample and scriptPath
Jenkinsfile-online
- Click branches
- See the
Update Time
column for tag row.
Does this PR introduced a user-facing change?
No
Fix an undefined latestRun exception
Additional documentation, usage docs, etc.:
/cc @kubesphere/sig-console