我已經意識到這個管道
send:
image: node:latest
before_script:
- git config --global user.email "[email protected]"
- git config --global user.name "Gitlab CI"
script:
- npm install
- npm run start $GMAIL_PW
- echo "Committing updated files to git"
- git add executions.txt
- git commit -m "Updated executions with new running date"
- git push "https://${GITLAB_USER_NAME}:${CI_ACCESS_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_REF_NAME}" -o skip-ci
only:
- schedules
有時沒有什么可以提交,并且管道失敗并出現此錯誤
$ git add executions.txt
$ git commit -m "Updated executions with new running date"
HEAD detached at 0fa2f4d
nothing to commit, working tree clean
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
當沒有什么可以提交時,如何防止管道失敗?
uj5u.com熱心網友回復:
您可以檢查 git 狀態,如果有要提交的內容,則僅提交和推送:
send:
image: node:latest
before_script:
- git config --global user.email "[email protected]"
- git config --global user.name "Gitlab CI"
script:
- npm install
- npm run start $GMAIL_PW
- |
CHANGES=$(git status --porcelain | wc -l)
if [[ "${CHANGES}" -gt 0 ]]; then
echo "Committing updated files to git"
git add executions.txt
git commit -m "Updated executions with new running date"
git push "https://${GITLAB_USER_NAME}:${CI_ACCESS_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_REF_NAME}" -o skip-ci
else
echo "Nothing to commit"
fi
only:
- schedules
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/431882.html
上一篇:當我克隆/拉取git專案檔案時,獲得-rw-r--r--權限。如何避免只讀訪問r--對git專案中機器上的每個人?
