Gradle-release plugin and SSH configuration in a Gitlab CI context

851 views Asked by At

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?

0

There are 0 answers