I used plugins/hg
to download mercurial repo successfully.
clone:
hg:
image: plugins/hg
path: bitbucket.org/orig/project-1
Doesn’t work with hg (mercurial repository)
But in terraform, to download terraform modules, I have below codes:
module "app" {
source = "hg::https://bitbucket.org/orig/project-1?rev=default"
....
}
When run terraform get
, it will download related modules (mercurial repositories) via hg command. I run this successfully on my laptop.
But have problem to run it in drone with container hashicorp/terraform
.
The exist official hashicorp/terraform
image only supports git, not mercurial command hg
. That’s fine. I create an image with this command:
$ cat Dockerfile
FROM hashicorp/terraform:0.10.3
RUN apk add --no-cache mercurial
I set this pipeline:
build:
image: 1234567890.dkr.ecr.ap-southeast-2.amazonaws.com/terraform:0.10.3-hg
commands:
- terraform get --update=true
- terraform init -backend-config=config/backend-${env}.conf
- terraform plan -var-file=config/${env}.tfvars -input=false -out=plan
Then I get authorization issue with new image:
- terraform get --update=true
Get: hg::https://bitbucket.org/orig/project-1?rev=default (update)
Error loading modules: error downloading ‘https://bitbucket.org/orig/project-1?rev=default’: /usr/bin/hg exited with 255: abort: http authorization required for https://bitbucket.org/orig/project-1
Works in git
I have another project with below pipeline, which use git as version control. I can run terraform get
in drone pipeline to download terraform module directly without any issue.
module "app" {
source = "git::https://bitbucket.org/orig/project-1?rev=default"
....
}
Pipeline:
build:
image: hashicorp/terraform:0.10.3
commands:
- terraform get --update=true
- terraform init -backend-config=config/backend-${env}.conf
- terraform plan -var-file=config/${env}.tfvars -input=false -out=plan
My questions:
How to fix this issue.
I am curious, how clone plugins/hg
works to download mercurial private repository without having this authorization issue.
How plugins/git
works with private repositories. How plugins/git
and plugins/hg
know and use the environment DRONE_BITBUCKET_CLIENT
and DRONE_BITBUCKET_SECRET
to download private repositories