fix(match): make git_private_key path absolute #21360
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validci/circleci
builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
When sending a path to a
git_private_key
(instead of key content), it fails when it tries to push changes to repository with errorResolves #19266
Description
I first noticed issue when
readonly
was set totrue
andgit_private_key: 'id_rsa'
in CI. It was able to clone the repo but it failed when trying to push changes back to repo. The problem started here. When it tried push the change, it couldn't find the file so it used the content ofgit_private_key
as private key (which wasid_rsa
) and it failed. Next thing I tried is to check whatDir.pwd
is when it clones and tries to push change and found out that when pushing changes, it changes directory to where it cloned the repo.So for a solution I've made sure that the during initialization
git_private_key
is always defined as absolute path instead of relative.Testing Steps
If you checkout the
master
and setreadonly
totrue
and providegit_private_key
as a path (ie.id_rsa
) instead sending private key content, it will fail when it tries to push new certificates/profiles back to repository.Checking out this branch, the problem is resolved.