So I asked question before about merging gitlub runner into remote branch, but I have made a lot of changes since then. The whole idea behind what I want is that I have a simple script which creates Excel file on runner and I want to push whole runner into a branch. I managed to add SSH key to my runner and I don't get any errors with it so I guess it's ok, but I get the error when I try to push from runner to my remote branch. The error I get is:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I think It may be a problem with a way that I push or something. Right now my pushing job is a little bit of a frankenstein created from parts from other threads on stack. The whole code:
variables:
GIT_STRATEGY: clone
build-job:
stage: build
tags:
- example_repo
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$GIT_SSH_PRIV_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$GIT_SSH_PRIV_KEY" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- echo SSH added
script:
- echo "Hello!"
- ls
- python3 -V
- pip3 list
test-job1:
stage: test
tags:
- example_repo
script:
- python3 Experiments/ConfigAutomation.py
test-job2:
stage: test
tags:
- example_repo
script:
- git config user.email "user@mymail.com"
- git config user.name "username"
- git checkout -b ci_processing
- git show-ref
- git remote -v
- git remote set-url --push origin git@gitlab/example_repo.git
- git add .
- git commit --amend --reset-author --allow-empty -m "Files from runner to branch"
- git push origin ci_processing:automation-test || true
- echo "Pushed"
deploy-prod:
stage: deploy
tags:
- example_repo
script:
- echo "This job deploys something."
close-conn:
stage: .post
tags:
- example_repo
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- eval '/usr/bin/ssh-agent -k'