Retrieve Git Submodule's Version Information

Hi,

for a project we are using we have recently added Git submodules. It is important for us to know, which commits are actually included in a build. Using 'git submodule status' will give us that information. However we have not been able to come up with a configuration, that would give us (a) the status for a specific changeset that get's build and (b) do that automatically. I gave the repository post-checkout hook a try. It get's copied to the rc/.../.git/hooks folder. It does not get fired though. The configuration key "Continua.ExecuteRepositoryServerSideScripts" is set to "CurrentRepositoryFoldersOnly".

Any ideas appreciated.

Thomas

Hi Thomas,

The Git post-checkout hook is working ok for us with the Continua.ExecuteRepositoryServerSideScripts key set to  “CurrentRepositoryFoldersOnly” . 

Can you let us know your repository settings - particularly the fields on the Scripts tab. What is the expected output of the post-checkout script? Is it set up to create a file? Is the path of this file included in the Post Checkout Output Paths box? Check whether the output file is being copied to the build workspace, or not, by enabling the “Log repository file copied” on the Repository Rules tab of the Stage Options for the relevant stage. Also check if there are any errors in the Event Log.

Note that any changes to the Scripts settings will only be used when checking out new changesets and will not be applied to existing changesets which have already been checked out when the repository was polled.

If you can send us the script file - to support at finalbuilder.com - we’ll have a go at running it here. Otherwise, if you can enable debug logging, restart the server service, add a new changeset to your repository, run a build to ensure that it is checked out and then send us the debug log, we’ll look into what is happening.

Hi,

these are my [Scripts] settings:

Post-Checkout Script  [subfolder\post-checkout]
[X] Run as Git hook
Post Checkout Output Paths [./]

I also tried [] and [.] as the output path. No difference though.

script “post-checkout”

#!/bin/sh
git submodule status >submodules.txt

Yes, the hook is meant to create a file. It should be created in the project root. If i do checkout myself in \ContinuaCI\Rc<id>\ the file gets created.

Repo Log entry

$Source.MyRepo$\submodules.txt > C:\ContinuaCI\CI_WS\Ws\43756\App
20:22:46  [Warning] 0 files



Question

Ok, let’s suppose this can be figured out, would it fulfill my requirement? That is, provide a submodules.txt on the changeset that gets build?

Thomas

Hi Thomas,

Try changing your Post Checkout Output Paths field to [submodules.txt]. The field takes an ANT pattern and is used to exclude files and folders from the cleanup function which removes any unversioned files from the repository cache before committing.

Once this is working it should add submodules.txt to the workspace as required. Note that the next release of Continua CI will include details of submodules in the changeset details xml file if this option is enabled on the repository.


Hi Dave,

thanks a lot for your help. I can now get a copy of the file created by the hook. However it is not related to the changeset that is used by the build. This is no problem though, as the latest release of Continua v1.8.1.849 provides the desired information :) All i had to do is add ''$Source.MyRepoName$\_CI_ChangesetDetails.xml' Output'; to the repository rules defined for the stage. That's awesome. Just like you guys reading my mind. :)

Thomas


Hi Thomas,

Great that the new changeset details xml file is giving you the desired information. Note that you should not need to add a rule for this file to the repository rules, as long as you have at least one rule for the relevant repository.

The reason that the post-checkout hook script was not outputing details of the latest submodules, is because we run 'git checkout' without the --recurse-submodules option followed by git submodule update. The post checkout hook runs directly after the checkout before the submodules are updated. We'll look into whether we can change this to use the --recurse-submodules option on the checkout command.

Note, if you untick the 'Run as Git hook' option, then the script is run after the 'git submodule update', so you should then get the correct results.

Hi Dave,

thanks for the clarifications. It's good to know my options.

Thomas