diff --git a/js/params.js b/js/params.js index 78bdb06..a542c6e 100644 --- a/js/params.js +++ b/js/params.js @@ -133,7 +133,17 @@ new Vue({ var causes = actions[i].causes; for (var cIndex = 0; cIndex < causes.length; cIndex++) { var shortDescription = causes[cIndex].shortDescription; - _self.causes.push(shortDescription) + var upstreamUrl = ''; + if (causes[cIndex].upstreamUrl && causes[cIndex].upstreamBuild) { + var rootUrl = _self.getJenkinsRootUrl(data.url, data.fullDisplayName); + if (rootUrl) { + upstreamUrl = rootUrl + '/' + causes[cIndex].upstreamUrl + causes[cIndex].upstreamBuild + '/' + } + } + _self.causes.push({ + shortDescription: shortDescription, + url: upstreamUrl + }) } } } @@ -222,5 +232,24 @@ new Vue({ console.log('window', window) }) }, + getJenkinsRootUrl(url, fullDisplayName) { + if (url[url.length - 1] === '/') { + url = url.substring(0, url.length - 1); + } + fullDisplayName = encodeURIComponent(fullDisplayName); + // %20%C2%BB%20: ยป + // %20%23: # + var path = fullDisplayName.replace('%20%C2%BB%20', '/job/').replace('%20%23', '/'); + path = '/job/' + path; + var index = url.lastIndexOf(path); + if (index > 0) { + var rootUrl = url.substring(0, index); + console.log('rootUrl', rootUrl); + return rootUrl + } else { + console.log('error: url:', url, 'fullDisplayName', fullDisplayName, 'path:', path); + return '' + } + }, } }); diff --git a/params.html b/params.html index 8473b51..350feac 100644 --- a/params.html +++ b/params.html @@ -63,7 +63,10 @@
- {{cause}}
+ {{cause.shortDescription}} + + +