Accessing another repo during build
I would like to push build artifacts to another repo during a build. After building the source code repo in the build_script section, I am attempting to clone the artifact repo in the on_success section, so that I can commit and push the artifacts. I followed the instructions in the post at this url, but I still get failed authentication:
https://help.appveyor.com/discussions/problems/555-accessing-another-repository-during-a-build
# from my appveyor.yml file:
on_success:
- cmd: cd ../
- git clone https://$($env:github_token):x-oauth-basic@github.com/csalmon1/BAC.git C:\projects\BAC
- cmd: cd BAC && pwd && dir
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 11 May, 2022 03:06 AM
This guide is more cool: https://www.appveyor.com/docs/how-to/git-push/
2 Posted by Colby Salmon on 11 May, 2022 08:47 PM
I did this, but it still didn't work. Instead of giving a failed authentication error like before, it just hung (must be waiting for credentials). Also I had to change directories and init since I'm changing repos.
environment:
access_token:
secure: svD9dHltYqXJZJFxS8q9W86QjQ7TLAaKLqXOjAVzwJ+v1lQ8mz8fK3dI6Te6OOGF
on_success:
- cmd: cd ../ && mkdir BAC && cd BAC
- git init
- git config --global credential.helper store
- ps: Set-Content -Path "$HOME\.git-credentials" -Value "https://$($env:access_token):x-oauth-basic@github.com`n" -NoNewline
- git config --global user.name "csalmon1"
- git config --global user.email "[email blocked]"
- git pull https://github.com/csalmon1/BAC.git
- cmd: pwd && dir
Support Staff 3 Posted by Feodor Fitsner on 11 May, 2022 09:38 PM
Make sure you are not testing it in PR build as secure variables are not set in PR builds.
4 Posted by Colby Salmon on 11 May, 2022 10:37 PM
I don't think it's a PR build. How do I check and make sure? If so, how do I change it?
The first repo accessed for the build is a public github repo. The second repo I am trying to access to push the build artifacts is a private github repo.
5 Posted by Colby Salmon on 11 May, 2022 10:40 PM
I am the owner of both repos.
Support Staff 6 Posted by Feodor Fitsner on 11 May, 2022 10:54 PM
Well, it's hard to tell what's wrong with your code - it looks OK to me. Try connecting to a build VM via RDP and experiment from there.
7 Posted by Colby Salmon on 12 May, 2022 01:17 AM
It seems to work when I push back to the same repo I started with, but it doesn't work to switch and pull or clone from a different repo.
Support Staff 8 Posted by Feodor Fitsner on 12 May, 2022 02:19 AM
Perhaps you should add/update remote?
9 Posted by Colby Salmon on 12 May, 2022 11:10 PM
Here is some console output that shows I have successfully configured the repo and set the remote url:
cd ../../ && pwd && mkdir BAC && cd BAC
/c/projects
git init .
Initialized empty Git repository in /c/projects/BAC/.git/
git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
git remote add origin https://github.com/csalmon1/BAC.git
git remote -v
origin https://github.com/csalmon1/BAC.git (fetch)
origin https://github.com/csalmon1/BAC.git (push)
git config --global credential.helper store
Set-Content -Path "$HOME\.git-credentials" -Value "https://$($env:access_token):x-oauth-basic@github.com`n" -NoNewline
git config --global user.name "csalmon1"
git config --global user.email "[email blocked]"
git fetch https://$($env:access_token):x-oauth-basic@github.com/csalmon1/BAC.git main
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/csalmon1/BAC.git/'
Command exited with code 128
When I did fetch command with no arguments, it hung and waited for credentials. When using fetch with arguments and token it fails to authenticate and tells me to use a token.
Support Staff 10 Posted by Feodor Fitsner on 12 May, 2022 11:47 PM
When you put credentials to
.git-credentials
I don't think you need to put them again in git fetch URL. Try just:Feodor Fitsner closed this discussion on 13 Jul, 2022 09:02 PM.