I have a repository that contains submodules. These are developed in a publicly accessible GitHub repository. My final deployment however is in a disconnected environment with mirrored GitHub repos in GitLab, which all require authentication.
My .gitmodules
file contains URLs for the publicly available repos. I did some sed
replacement in the job and can update them properly, but unfortunately, I'm then not able to authenticate, since it's a separate operation from the git url:....
step.
I can clone the project with:
git url: "[email protected]", branch: "master", credentialsId: "somecredentialid"
This doesn't update my submodules though unfortunately. And since I require authentication.
I also can clone using the checkout
:
checkout([
$class: 'GitSCM',
branches: [[name: 'master']],
doGenerateSubmoduleConfigurations: true,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '', trackingSubmodules: true]],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'somecredentialid',
url: '[email protected]']]
])
}
}
It isn't clear to me from the documentation what doGenerateSubmoduleConfigurations: true,
and submoduleCfg:
are for.
I feel like the checkout
way might be the solution, but I can't figure out how to update the .gitmodules
to reflect the secured URLs for the submodules.
If we commit and push to a submodule, The main project's repo now points to our current submodule's commit. Now we need to commit the update to the main project. Recap: We have included a submodule in our project, updated it's contents, and pushed back to it's repository, all from our main project.
Pushing updates in the submodule. The submodule is just a separate repository. If you want to make changes to it, you should make the changes in its repository and push them like in a regular Git repository (just execute the git commands in the submodule's directory).
git submodule sync synchronizes all submodules while git submodule sync -- A synchronizes submodule "A" only. If --recursive is specified, this command will recurse into the registered submodules, and sync any nested submodules within.
The quickest way to rename a submodule might be via the Course Builder tool. If you go to Course Admin > Course builder, you will see the structure of your content. Simply click on the submodule > Edit and you can rename the submodule in the new window that opens up.
This works for me in my case which is similar to what you trying to do here; see if this helps.
checkout changelog: true, poll: true, scm: [
$class: 'GitSCM',
branches: [[name: "master"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption', recursiveSubmodules: true, parentCredentials: true], [$class: 'PruneStaleBranch']],
submoduleCfg: [],
userRemoteConfigs: [[name: 'origin', url: "Git ssh URL/${projectName}.git", credentialsId: 'Git credential']]
]
Having bashed my head against this a while too, here's what I found.
doGenerateSubmoduleConfigurations
is exposed as scm.doGenerateSubmoduleConfigurations
which suggests that it invokes SubmoduleCombinator
. That doesn't look like what you want at all. The option should probably be (a) in an extension not the core plugin and (b) be called doGenerateSubmoduleCombinationMatrix
or something.
submoduleCfg
doesn't seem to get much obvious use in the git plugin. All I found for it was tests where it's empty.
Functionality seems to have moved into SubmoduleOption
. This has method onCheckoutCompleted(...)
that calls git.submoduleUpdate(...)
.
So AFAICS the extensions
entry for class SubmoduleOption
is what you want. And the docs are a bit special.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With