I am using gitlab CI runner to test my code and generating some files. I just want to push the generated files to gitlab repository via CI runner. Is there any way to do that ?
I have resolved this issue by doing this:
Note: If you want to git push to a non protected branch do not set the runner variable as protected
User Settings > Access Tokens
Your project > Settings > Secret variable
using variable name CI_PUSH_TOKEN
CI_USERNAME
Then you can use this token instead of the default in you gitlab-ci script. for example:
before_script: - git remote set-url origin https://${CI_USERNAME}:${CI_PUSH_TOKEN}@gitlab.com/${CI_PROJECT_NAME}.git - git config --global user.email '${GITLAB_USER_EMAIL}' - git config --global user.name '${GITLAB_USER_ID}' ... - git checkout -B branch - # do the file changes here - git commit -m '[skip ci] commit from CI runner' - git push --follow-tags origin branch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With