-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Minor
-
Component/s: git-plugin
Hello,
Currently there is no way to specify a Browser for linking to the commit/files/diffs for changes.
Either there should be a way to specify the Browser in the Piepeline configuration, or there should be a way to - for example - add the browser to the scm variable.
A third option would be to allow configuring a global mapping between the "host:port" of a connection to a browser. I coded such a scheme and it works for normal Pipelines, but it doesnt for Multibranch Pipeline.
With this one could set a mapping from the clone-urls to the projects web-url and additional stuff like browser information
@NonCPS
def call(name) {
def servermap = [
'localhost:10022': [browser: [$class: 'GogsGit', repoUrl: 'http://localhost:10080'],
credentialsId: 'aad288c5-ea8e-4484-8e2d-9dc7abab7910', ],
]
def repomap = [
'tools': [git: 'ssh://git@localhost:10022/mn/tools.git', ],
'firmware': [git: 'ssh://git@localhost:10022/mn/firmware.git', ],
'jenkins-jobscripts': [git: 'ssh://git@localhost:10022/mn/jenkinspipeline.git', ],
]
def repo = repomap[name]
if (repo != null) {
repo = repo.clone()
def url = repo['git']
if (url != null) {
url = url - '.git'
def m = (url =~ '.*://(.*@)?([^#/]*)/([^#]*)')
def repohost = m[0][2].trim()
def vcsurl = m[0][3].trim()
def serverinfo = servermap[repohost]
if (serverinfo != null) {
if (serverinfo.browser?.repoUrl != null) {
// take the path component of the clone url, and apeend to the
// base webpage-url from the server
def browser = [:] + serverinfo.browser
browser['repoUrl'] = browser['repoUrl'] + '/' + vcsurl
serverinfo = [:] + serverinfo
serverinfo['browser'] = browser
}
repo.putAll(serverinfo)
}
}
}
return repo
}