I am new to using Gitlab runners and am trying to write a pipeline that changes a file and then commits and pushes this file to main. I have run into a multitude of different errors while trying to do this and trying other solutions. If anyone has suggestions of solutions that have worked for them, that would be greatly appreciated.
This is what I have in my gitlab-ci.yml file:
`stages:
- build
write_logfile:
stage: build
script:
- echo "This is a log message" > logfile.txt
- git config user.email "[email protected]"
- git config user.name "access-token-name"
- git remote add gitlab_origin
- https://oauth2:[email protected]/path-to-project.git
- git add .
- git commit -m "push back from pipeline"
- git push gitlab_origin HEAD:main -o ci.skip
rules:
- changes:
- 'Source/*'`
I found this from this page but I keep receiving the following error: remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password.
My account does not have 2FA so I am not sure what I'm doing wrong.
I changed a few things to solve this problem:
Setting the
GIT_STRATEGYvariable toCloneChecking out a branch to avoid detached head, and correctly using the project access token (see below)