Bitbucket pipeline does not handle relative git submodule url for ssh checkout?

I have a bitbucket hosted git repository, which has a git submodule repo. I'd like to use a relative url, to allow both https and ssh usage, in the .gitmodules file:

[submodule "sm-ourlib"]
path = sm-ourlib
# url = [email protected]:companyname/ourlib.git
# Use relative url to allow for both HTTP and SSH access, see https://stackoverflow.com/a/44630028/50899
url = ../ourlib.git

However, it seems bitbucket pipelines can't handle the relative url as expected, since it doesn't use ssh for the subrepo for relative urls, but instead uses https and fails. (for the absolute url, it uses ssh correctly).

The pipeline run fails in the git submodule update --init step with:

+ git submodule update --init
Submodule 'sm-ourlib' (http://bitbucket.org/companyname/ourlib.git) registered for path 'sm-ourlib'
Cloning into '/opt/atlassian/pipelines/agent/build/sm-ourlib'...
fatal: could not read Username for 'https://bitbucket.org': No such device or address
fatal: clone of 'http://bitbucket.org/companyname/ourlib.git' into submodule path '/opt/atlassian/pipelines/agent/build/sm-ourlib' failed
Failed to clone 'sm-ourlib'. Retry scheduled
Cloning into '/opt/atlassian/pipelines/agent/build/sm-ourlib'...
fatal: could not read Username for 'https://bitbucket.org': No such device or address
fatal: clone of 'http://bitbucket.org/companyname/ourlib.git' into submodule path '/opt/atlassian/pipelines/agent/build/sm-ourlib' failed
Failed to clone 'sm-ourlib' a second time, aborting

Is this a known issue, or am I doing something wrong?


I was facing the same issue. Bitbucket is using https during the checkout hence the relative URLs are resolved with https, too. With the following hack the build pipeline can be patched to rewrite the .gitmodules files:

          script:
            - sed -i 's/url = \.\.\(.*\)/url = [email protected]:<your org>\1\.git/g' .gitmodules
            - git submodule update --init