Adds option to specify secret id for github
Same as existing bitbucket checkout-over-ssh ssh-checkout for github must needs the option for a user to specify the id of the secret containing the ssh credentials to be used for checkout. Change-Id: I675c94c971e78d6ecd71d6f1446e0388430dab80 Signed-off-by: sbussetti <steve.bussetti@gmail.com>
This commit is contained in:
parent
20f561c55d
commit
dab3156465
|
@ -745,7 +745,11 @@ def github_scm(xml_parent, data):
|
||||||
|
|
||||||
:arg str api-uri: The GitHub API uri for hosted / on-site GitHub. Must
|
:arg str api-uri: The GitHub API uri for hosted / on-site GitHub. Must
|
||||||
first be configured in Global Configuration. (default GitHub)
|
first be configured in Global Configuration. (default GitHub)
|
||||||
:arg bool ssh-checkout: Checkout over SSH. (default false)
|
:arg bool ssh-checkout: Checkout over SSH.
|
||||||
|
|
||||||
|
* **credentials** ('str'): Credentials to use for
|
||||||
|
checkout of the repo over ssh.
|
||||||
|
|
||||||
:arg str credentials-id: Credentials used to scan branches and pull
|
:arg str credentials-id: Credentials used to scan branches and pull
|
||||||
requests, check out sources and mark commit statuses. (optional)
|
requests, check out sources and mark commit statuses. (optional)
|
||||||
:arg str repo-owner: Specify the name of the GitHub Organization or
|
:arg str repo-owner: Specify the name of the GitHub Organization or
|
||||||
|
@ -852,12 +856,21 @@ def github_scm(xml_parent, data):
|
||||||
helpers.convert_mapping_to_xml(
|
helpers.convert_mapping_to_xml(
|
||||||
bd, data, bd_mapping, fail_required=True)
|
bd, data, bd_mapping, fail_required=True)
|
||||||
|
|
||||||
if data.get('ssh-checkout', False):
|
if data.get('ssh-checkout', None):
|
||||||
XML.SubElement(
|
cossh = XML.SubElement(
|
||||||
traits, ''.join([
|
traits, ''.join([
|
||||||
github_path_dscore, '.SSHCheckoutTrait'
|
github_path_dscore, '.SSHCheckoutTrait'
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
if not isinstance(data.get('ssh-checkout'), bool):
|
||||||
|
cossh_credentials = [
|
||||||
|
('credentials', 'credentialsId', ''),
|
||||||
|
]
|
||||||
|
helpers.convert_mapping_to_xml(
|
||||||
|
cossh,
|
||||||
|
data.get('ssh-checkout'),
|
||||||
|
cossh_credentials,
|
||||||
|
fail_required=True)
|
||||||
|
|
||||||
if data.get('discover-tags', False):
|
if data.get('discover-tags', False):
|
||||||
XML.SubElement(
|
XML.SubElement(
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
<org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
|
<org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
|
||||||
<strategyId>3</strategyId>
|
<strategyId>3</strategyId>
|
||||||
</org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
|
</org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
|
||||||
<org.jenkinsci.plugins.github__branch__source.SSHCheckoutTrait/>
|
<org.jenkinsci.plugins.github__branch__source.SSHCheckoutTrait>
|
||||||
|
<credentialsId>ssh_secret</credentialsId>
|
||||||
|
</org.jenkinsci.plugins.github__branch__source.SSHCheckoutTrait>
|
||||||
<org.jenkinsci.plugins.github__branch__source.TagDiscoveryTrait/>
|
<org.jenkinsci.plugins.github__branch__source.TagDiscoveryTrait/>
|
||||||
<org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
|
<org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
|
||||||
<strategyId>3</strategyId>
|
<strategyId>3</strategyId>
|
||||||
|
|
|
@ -4,7 +4,8 @@ script-path: some.Jenkinsfile
|
||||||
scm:
|
scm:
|
||||||
- github:
|
- github:
|
||||||
api-uri: http://example.org/github
|
api-uri: http://example.org/github
|
||||||
ssh-checkout: true
|
ssh-checkout:
|
||||||
|
credentials: 'ssh_secret'
|
||||||
repo: example-repo
|
repo: example-repo
|
||||||
repo-owner: example-owner
|
repo-owner: example-owner
|
||||||
credentials-id: example-credential
|
credentials-id: example-credential
|
||||||
|
|
Loading…
Reference in New Issue