{GoCD 17.10] Issue cloning git submodules

485 views
Skip to first unread message

yas...@odoc.life

unread,
Aug 1, 2018, 7:52:10 AM8/1/18
to go-cd
Hi,
I have a git repository with a single git submodule which goCD is not able to clone. It gives the following error:

pr|10:07:42.582 [GIT] Fetching changes
pr|10:07:42.886 [GIT] Performing git gc
pr|10:07:42.991 [GIT] Reset working directory pipelines/odoc-patient
pr|10:07:42.991 [GIT] Cleaning all unversioned files in working copy
pr|10:07:42.996 [GIT] Cleaning submodule configurations in .git/config
pr|10:07:42.997 [GIT] Updating working copy to revision 7a54bc8dd6afa272d8c1dc793a4a7f871a500afa
pr|10:07:43.016 HEAD is now at 7a54bc8 Commit name
pr|10:07:43.016 [GIT] Removing modified files in submodules
pr|10:07:43.030 [GIT] Updating git sub-modules
&2|10:08:10.887 Error performing command: --- Command ---
&2|10:08:10.887 git submodule update
&2|10:08:10.887 --- Environment ---
&2|10:08:10.887 {}
&2|10:08:10.887 --- INPUT ----
&2|10:08:10.887
&2|10:08:10.887
&2|10:08:10.887 --OUTPUT ---
&2|10:08:10.887
&2|10:08:10.887 --- ERROR ---
&2|10:08:10.887 STDERR: Cloning into 'submodulename'...
&2|10:08:10.887 STDERR: fatal: reference is not a tree: b79aacd45e81fadbb5a4f13009bd13f6a47d9958
&2|10:08:10.887 STDERR: Unable to checkout 'b79aacd45e81fadbb5a4f13009bd13f6a47d9958' in submodule path 'submodulename'
&2|10:08:10.887 ---
&2|10:08:10.887
ex|10:08:10.896 [go] Job completed odoc-patient/1/debugApk/1/defaultJob on ip [/home/ubuntu/soft/go-agent-17.10.0]

 Is this a known issue or is there any workaround for submodules in goCD?

Thanks a lot. 

Aravind SV

unread,
Aug 1, 2018, 6:37:17 PM8/1/18
to go...@googlegroups.com
Submodules should work. What happens if you do this locally:

git clone git://the-url some-dir
cd some-dir
git submodule update

Cheers,
Aravind
> --
> You received this message because you are subscribed to the Google Groups "go-cd" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Yasiru Kassapa

unread,
Aug 2, 2018, 3:12:18 PM8/2/18
to go...@googlegroups.com
Hi Aravind thanks for the reply. I followed your instructions on my local machine on git 2.15.0. Following were my findings. 

1. 

git clone git://the-url some-dir
cd some-dir
git submodule update

clones the repository but git submodule update doesn't update the submodule or output any content to console or return an error value. 

2. 

git clone git://the-url some-dir
cd some-dir
git submodule update --init

clones the repository and git submodule update --init successfully clones the submodule and outputs the following:

Submodule 'submodule' (https://gitrepourl.git) registered for path 'submodule'
Cloning into repopath/submodule'...
Submodule path 'submodule': checked out '<commit id>'

Reading the git documentation for submodules it seems that --init flag resolves the url for the submodule and adds an entry to it to the .git/config file in the repository and then  . 
Immediately after cloning a repository if i manually add the submodule entry to .git/config file git submodule update works. 

Should GoCD be running git submodule update --init instead of git submodule update when cloning a repository?

Thanks again. 


> To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+unsubscribe@googlegroups.com.

Ankit Srivastava

unread,
Aug 2, 2018, 6:35:25 PM8/2/18
to go...@googlegroups.com
Hi Yasiru,

Following git commands are run by GoCD when it needs to update a git material (with submodule) to a given revision (REVISION).

  git config remote.origin.url
  git rev-parse --abbrev-ref HEAD
  git fetch origin --prune
  git gc --auto
  git config --get-regexp ^submodule\..+\.url

  git clean -dff         #In each submodule directory
  git clean -dff
  git config --get-regexp ^submodule\..+\.url
  
  git config --remove-section submodule.NAME  # For each submodule, named NAME
  git reset --hard
  git submodule foreach --recursive git checkout .
  git submodule init at
  git submodule sync at
  git submodule foreach --recursive git submodule sync
  git submodule update
  git submodule status
  git config --get-regexp ^submodule\..+\.url
  git clean -dff   #In each submodule directory
  git clean -dff

I found this article (https://stackoverflow.com/questions/2155887/git-submodule-head-reference-is-not-a-tree-error) which had similar issue with git submodules. would you mind trying it out and see if that helps.

Regards,
Ankit  



> To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages