CIRCLE_REPOSITORY_URL changed format in v2

envars
cci-20

#1

I have noticed the CIRCLE_REPOSITORY_URL variable that CircleCi provides in builds (docs) has changed between v1 and v2. I migrated a project and in v1 I got a format of https://github.com/company/repo but in v2 I get a format of git@github.com:company/repo.git. i.e. I now get the ssh clone string. I would argue that the new format isn’t a URL so should be called by a different ENV var name.

The reason this is a problem is that we use this ENV var in a Slack message to the dev team to link to the repo being built, and the link is broken since migrating to v2. Apart from this small thing, the migration was fantastic, the build is 5 minutes faster which we are very happy about.


Checkout with https rather than git protocol
#2

Hi,

I’m not 100% sure just yet but that might be a bug. I’ve filed in internal issue to get this solved. Thank you for letting us know.


#3

I’d like to checkout my source using https rather than git protocol. It’s a public repo. I believe the default was https with CircleCI 1.0. I’ve removed the ssh deploy key from my CircleCI configuration. I don’t see a parameter to the checkout command of .circleci/config.yml to specify the git protocol.
https://circleci.com/docs/2.0/configuration-reference/#checkout

I currently have:
CIRCLE_REPOSITORY_URL=git@github.com:Linuxbrew/homebrew-extra.git
I’d like:
CIRCLE_REPOSITORY_URL=https://github.com/Linuxbrew/homebrew-extra.git

Thanks!
Shaun


#4

The workaround that I’m using is to set the environment variable CIRCLE_REPOSITORY_URL in my .circleci/config.yml. See for example https://github.com/Linuxbrew/brew/blob/master/.circleci/config.yml#L7

Cheers,
Shaun


#5

The change appears to be intentional. I see the following code in the “Checkout” stage. Is this code in CircleCI’s GitHub somewhere? https://github.com/circleci

# use git+ssh instead of https
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true

Cheers,
Shaun


#6

Thanks for the info. You inspired me to do a similar fix. In my case it was in Ansible code using jinja2 replace() to “fix” the repo url in a slack message

"<{{ repourl | replace('git@github.com:','https://github.com/') | replace('.git','') }}/commit/{{ gitcommit | default('?') }}|{{ gitcommit | truncate(7, True) }}>"

#7

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.