我刚开始使用GitLab CI/CD作业,但是我正在尝试设置一个Python脚本,当推送到GitLab时触发CI/CD作业运行,并调用一个内部函数,条件满足时再次推送到GitLab。举个例子,假设我有以下内容:
def hasFileInDirectory():
# checks if the current directory has at least 1 other file in it
if (1 or more files exist):
print 'Great! You have enough files!';
else:
print 'Oh no! You need more files! Let me create one!';
createFile('missingFile'+str(random.randint(0,1000000)+'.txt');
os.system('git add -A');
os.system('git commit -m "Automatically added new file..."');
os.system('git push origin HEAD:master --force');
如果我从命令行自己运行这个函数,它似乎可以完美地运行,但是在GitLab CI/CD工作中似乎无法运行。我得到的输出是:
remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab-ci-token:xxxxx@gitlab.com/path_to/my_repository.git/': The requested URL returned error: 403
当我调用git push
时出现此错误,我想知道我该怎么做才能修复这个问题。我真的很感激任何帮助!