Add support for Stash as a repository viewer

Make it possible to use Atlassian Stash as a repository viewer of Git
SCM changes. Also sort the viewers alphabetically.

Change-Id: I6725570a0aa6770b2d0eee2cd0ae5ff0e5c5e07c
This commit is contained in:
Peter Jönsson 2014-03-18 11:05:54 +01:00
parent 3ddbf020e0
commit 00a1c332e5
3 changed files with 60 additions and 9 deletions

View File

@ -79,14 +79,17 @@ def git(self, xml_parent, data):
:arg str git-config-email: Configure email for Git clone :arg str git-config-email: Configure email for Git clone
:browser values: :browser values:
:githubweb: :auto:
:fisheye:
:bitbucketweb: :bitbucketweb:
:cgit:
:fisheye:
:gitblit: :gitblit:
:githubweb:
:gitlab: :gitlab:
:gitoriousweb: :gitoriousweb:
:gitweb: :gitweb:
:redmineweb: :redmineweb:
:stash:
:viewgit: :viewgit:
:choosing-strategy values: :choosing-strategy values:
@ -189,22 +192,23 @@ def git(self, xml_parent, data):
XML.SubElement(scm, 'localBranch').text = data['local-branch'] XML.SubElement(scm, 'localBranch').text = data['local-branch']
browser = data.get('browser', 'auto') browser = data.get('browser', 'auto')
browserdict = {'githubweb': 'GithubWeb', browserdict = {'auto': 'auto',
'fisheye': 'FisheyeGitRepositoryBrowser',
'bitbucketweb': 'BitbucketWeb', 'bitbucketweb': 'BitbucketWeb',
'cgit': 'CGit', 'cgit': 'CGit',
'fisheye': 'FisheyeGitRepositoryBrowser',
'gitblit': 'GitBlitRepositoryBrowser', 'gitblit': 'GitBlitRepositoryBrowser',
'githubweb': 'GithubWeb',
'gitlab': 'GitLab', 'gitlab': 'GitLab',
'gitoriousweb': 'GitoriousWeb', 'gitoriousweb': 'GitoriousWeb',
'gitweb': 'GitWeb', 'gitweb': 'GitWeb',
'redmineweb': 'RedmineWeb', 'redmineweb': 'RedmineWeb',
'viewgit': 'ViewGitWeb', 'stash': 'Stash',
'auto': 'auto'} 'viewgit': 'ViewGitWeb'}
if browser not in browserdict: if browser not in browserdict:
valid = sorted(browserdict.keys())
raise JenkinsJobsException("Browser entered is not valid must be one " raise JenkinsJobsException("Browser entered is not valid must be one "
"of: githubweb, fisheye, bitbucketweb, " "of: %s or %s." % (", ".join(valid[:-1]),
"cgit, gitblit, gitlab, gitoriousweb, " valid[-1]))
"gitweb, redmineweb, viewgit, or auto")
if browser != 'auto': if browser != 'auto':
bc = XML.SubElement(scm, 'browser', {'class': bc = XML.SubElement(scm, 'browser', {'class':
'hudson.plugins.git.browser.' + 'hudson.plugins.git.browser.' +

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
<url>ssh://git@stash.example.com:/foo/bar.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>origin/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<excludedUsers/>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>true</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir/>
<reference/>
<gitConfigName/>
<gitConfigEmail/>
<skipTag>false</skipTag>
<scmName/>
<useShallowClone>false</useShallowClone>
<browser class="hudson.plugins.git.browser.Stash">
<url>https://stash.example.com/projects/foo/repos/bar/</url>
</browser>
</scm>
</project>

View File

@ -0,0 +1,7 @@
scm:
- git:
url: "ssh://git@stash.example.com:/foo/bar.git"
branches:
- origin/master
browser: stash
browser-url: "https://stash.example.com/projects/foo/repos/bar/"