I have:
- main github repo with Terraform12 code
- module in secondary repo which is referred as
source = "git@github.com:user/mod_repo?ref=v1.0.0"
- Jenkins 2.249 (can't update now)
- a private ssh key in Jenkins to access
mod_repo
When I try to run terraform init
in Jenkins pipeline I get
Could not download module "vpc" (main.tf:1) source code from
"git@github.com:user/mod_repo?ref=v1.0.0": error downloading
'ssh://git@github.com/user/mod_repo?ref=v1.0.0': /usr/bin/git exited
with 128: Cloning into '.terraform/modules/vpc'...
Permission denied (publickey).
Locally I can do it without issues.
How should I configure the key in Jenkinsfile
* (or where else?) to allow access to the secondary repo?
I've seen this, this, this and this but cannot figure out how to connect it together.