snippetMinor
How to use Jenkins to manage a repository from Github with a submodule from Bitbucket?
Viewed 0 times
fromjenkinswithgithubbitbucketmanagerepositoryhowusesubmodule
Problem
For my Jenkins build, I need to manage a Github repository to automate building a project. However, the issue is that this repository needs to pull a submodule from Bitbucket. This requires two difference instances of authentication, one for each service. As of now, Jenkins is only allowing the use of a single set of credentials, using a username and SSH key. Is there a way to specify a different set of credentials for each pull?
Solution
It is a convenience that Jenkins will pull from git for you. With such a complex setup as needing to pull from two repos you can simply use a pipeline job that runs "sh" to explicitly git checkout the code and pull the submodules:
The good news with this slightly manual approach is that you can debug the sh commands to run on a dev server and cut paste them straight into a pipeline. Just start a “sh” session (usually it runs bash) and test the commands.
sh "git checkout ${custom_env_var} ${custom_parameter}The good news with this slightly manual approach is that you can debug the sh commands to run on a dev server and cut paste them straight into a pipeline. Just start a “sh” session (usually it runs bash) and test the commands.
Code Snippets
sh "git checkout ${custom_env_var} ${custom_parameter}Context
StackExchange DevOps Q#4725, answer score: 2
Revisions (0)
No revisions yet.