1

I'm using gradle-release plugin in a CI/CD context with GitLab-CI.

I have set up a public private key in GitLab to allow my pipeline to push stuff in the repo but I have an issue, I guess, with how to pass SSH info to gradle process.

In my pipeline script, I have a before_script and I do

- eval $(ssh-agent -s)
- bash -c 'ssh-add <(echo "${MY_SSH_PRIVATE_KEY}")'

MY_SSH_PRIVATE_KEY is stored in the GitLab CI variables.

Then I set my remote url with the ssh style for git repo

git remote set-url origin git@${remoteUrl}

I checkout my branch

git checkout -B ${CI_COMMIT_REF_NAME} ${CI_COMMIT_SHA}

then I call for the plugin

./gradlew release --info -Prelease.useAutomaticVersion=true

I have a an issue during the plugin process

> Failed to run [git remote update] - [Fetching origin ][Host key
> verification failed. fatal: Could not read from remote repository.
> 
> Please make sure you have the correct access rights and the repository
> exists. error: Could not fetch origin ]

Do you have an idea on how to fix it?

Vít Kotačka
  • 1,472
  • 1
  • 15
  • 40
  • Why can't you do just got clone and checkout the branch. Does git fetch work via CLI? The Gradle plugin does a project exec and it might be that the ssh key is not available. I think the project exec always has a fresh env – Hillkorn Nov 09 '18 at 18:49
  • @Hillkorn In fact I want to make an automatic release pipeline using its plugin. I don't want to use the CLI. – Hervé Darritchon Nov 10 '18 at 19:03
  • Did you checked why "Host key verification failed." happens? Looks like your ssh config has trouble to very the host key. – Hillkorn Nov 12 '18 at 09:11
  • what I think cause this issue with SSH it's that the ssh config is not passed to the process running the release plugin. So I have this error. The shell has the config through ````bash -c 'ssh-add <(echo "${MY_SSH_PRIVATE_KEY}")'```` but the gradlew script isn't transfering the config to all the command it runs. – Hervé Darritchon Nov 12 '18 at 12:50
  • I'm having the same issue. did you manage to get a solution? – user2962698 Feb 10 '22 at 21:09

0 Answers0