6
我想在Linux上使用gitlab-runner在本地構建我的項目。Gitlab-runner本地構建 - 從非TTY設備登錄
docker-build:
stage: build
image: docker:latest
script:
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY # user "gitlab-ci-token" is automatically created by GitLab
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" target/
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
不幸的是,我的嘗試結束時出現關於「docker login」無法從非TTY設備進行交互式登錄的錯誤。
$ gitlab-ci-multi-runner exec docker --docker-privileged docker-build
Running with gitlab-ci-multi-runner 1.11.1 (a67a225)
on ()
Using Docker executor with image docker:latest ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Waiting for services to be up and running...
Pulling docker image docker:latest ...
Running on runner--project-1-concurrent-0 via vanqyard...
Cloning repository...
Cloning into '/builds/project-1'...
done.
Checking out 70187b2d as docker-basic-conf...
Skipping Git submodules setup
Checking cache for docker-build/docker-basic-conf...
Successfully extracted cache
$ docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
Error: Cannot perform an interactive login from a non TTY device
ERROR: Job failed: exit code 1
FATAL: exit code 1
我的問題是有人絆倒了這個問題,以及如何succesfunlly執行構建?
它不應該進入互動模式,因爲你提供的命令憑據命令
echo $CI_JOB_TOKEN
驗證這一點。你確定那些'gitlab-ci-token'和'$ CI_JOB_TOKEN'的雙引號嗎?也許這些憑據被誤解,因爲這些和登錄回落到交互模式? – Jawad擺脫引號給「標誌需要一個參數:'p'在-p」,所以我猜測引用的使用是正確的。 – asdfgh