error when use ‘git push ’ in gitlabci.yaml

Viewed 52

When I use .gitlabci.yaml to run the commit.sh it show errors when it come to git push.
Any idea please ?

-------.gitlabci.yaml ------

dist:
stage: dist
tags:
    - vasdev-jenkins
script:
    - sh ./ci/commit.sh
    - ls -lah
only:
    - feature/gitlabci
    - develop
dependencies:
    - build

-----commit.sh----

#!/bin/bash

git config --global user.email "xxx@xx.com"
git config --global user.name "xxx"
git remote rm origin
git remote add origin $DEPLOY_TOKEN_URL
git branch -D develop_test || true
git fetch origin
git checkout -b develop_test origin/develop_test -f
git checkout develop_test

mv -f dist/* ./


rm -rf dist

git add .
git commit -am "$CI_COMMIT_MESSAGE-$CI_COMMIT_SHORT_SHA"
git push origin develop_jenkins

enter image description here

1 Answers

First, you can check if the same push done manually on the GitLab job runner machine would work.

Second, check if a credential helper is set, by adding to your script, before the push:

git config credential.helper

The wrong credentials might have been cached.

If you are using https://username:password@remote//myrepo

  • make sure 2FA is not activated
  • make sure to use a token instead of the account password
Related