我在 GitLab 中有一个节点项目。我有 CI 设置来构建 Docker 映像并将其上传到 AWS ECR。三天前运行良好。
.gitlab-ci.yml
image: docker:latest
services:
- docker:dind
stages:
- build
variables:
REPOSITORY_URL: 708604513256.dkr.ecr.ap-south-1.amazonaws.com/foo-bar/api:latest
before_script:
- apk add --no-cache curl jq python py-pip
- pip install awscli
build:
stage: build
only:
- master
script:
- $(aws ecr get-login --no-include-email --region ap-south-1)
- docker build -t $REPOSITORY_URL .
- docker push $REPOSITORY_URL
Run Code Online (Sandbox Code Playgroud)
日志
Running with gitlab-runner 13.0.0 (c127439c)
on docker-auto-scale fa6cab46
Preparing the "docker+machine" executor
Using Docker executor with image docker:latest ...
Starting service …Run Code Online (Sandbox Code Playgroud) 我正在尝试测试我的 python 项目并通过 gitlab 运行。我已经在我的 ubuntu 笔记本上安装了 runner 并在本地 gitlab 服务器上完成注册。因此,得到了 2 台独立的机器,一台是运行器,另一台是 gitlab 服务器。两台机器可以互相通信。笔记本(192.168.100.10) ---- GitLab(172.16.10.100)
一旦我提交测试,我的工作就失败了,并显示以下消息;
Reinitialized existing Git repository in /builds/dz/mytest/.git/
fatal: unable to access 'http://gitlab.lab01.ng/dz/mytest.git/': Could not resolve host: gitlab.lab01.ng
Uploading artifacts for failed job
ERROR: Job failed: exit code 1
Run Code Online (Sandbox Code Playgroud)
从我的笔记本 cli 中,我可以 ping gitlab 服务器 ip,但不能 ping 通主机名,甚至 curl 也不知道主机名。我认为这与无法解析的 dns 有关。我在笔记本 /etc/hosts 中添加主机名,我可以 ping 主机名,但运行作业仍然失败,并显示相同的消息。我尝试过人们建议在 gitlab-runner config.toml 中添加以下内容,因此我在 config.toml 中添加以下内容(不确定在 config.toml 中添加是否正确)
[[runners]]
dns_search = [""]
Run Code Online (Sandbox Code Playgroud)
仍然失败并收到相同的消息无法重新同步主机。我可以在笔记本设置/跑步者上做什么?我没有 gitlab 的管理员权限来进一步检查。任何人都面临同样的问题。感谢您的帮助和支持。
--有关信息,我已尝试使用公共 gitlab (gitlab.com) 在我的笔记本上测试运行程序,并且我可以成功运行该作业,而不会出现任何错误消息--
我写了一个非常简单的 .gitlab-ci.yml 如下:
image: horchen/vscode-ext-dev
job1:
script:
- echo "Hello World"
Run Code Online (Sandbox Code Playgroud)
只是回显Hello World,我想它应该可以在任何平台上运行。但 gitlab-ci 总是告诉我其中有语法错误。
Running with gitlab-runner 13.2.2 (a998cacd)
on nodejs-ci aPuhC2uZ
Preparing the "docker" executor
Using Docker executor with image horchen/vscode-ext-dev ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:17af24ad877daa656e102508585c7262585be04b05a75cc89833afcfe7403ebb for horchen/vscode-ext-dev ...
Preparing environment
Running on runner-apuhc2uz-project-1-concurrent-0 via cf9f41a14878...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/horchen/vscode-rlcv/.git/
Checking out 93d3b0e1 …Run Code Online (Sandbox Code Playgroud) 如果某个文件存在,我想让 Gitlab Runner 中的作业失败。我怎样才能做到这一点?谢谢。
我将 gitlab.com 与我自己的运行程序一起使用(它们在我的服务器上执行)。
当在 shell 上下文中执行scriptin 中的条目时,文件在哪里创建?.gitlab-ci.yml例如,下面的示例在 shell 运行器上运行
script:
- date > hello.txt
Run Code Online (Sandbox Code Playgroud)
我应该去哪里寻找hello.txt?
这个问题的具体原因是为了清理目的:我想删除我的跑步者创建并填充临时数据的旧目录。
如何使用共享运行器从 git 管道构建我的 iOS 项目?
出现错误- 执行作业脚本的“step_script”阶段
/bin/sh: eval: 第 92 行: xcodebuild: 未找到
$ xcodebuild clean -project CI-Demo-iOS/CI-Demo-iOS.xcodeproj -scheme CI-Demo-iOS 错误:作业失败:退出代码 127
脚步 -
使用window操作系统将gitlab-ci.yaml推送到git。
gitlab-ci.yaml 文件有-
脚本:
- xcodebuild clean -project CI-Demo-iOS/CI-Demo-iOS.xcodeproj -scheme CI-Demo-iOS
Run Code Online (Sandbox Code Playgroud) 我想用我的管道运行我的 Jupyter 笔记本。为此,我需要runipy。要在 gitlab runner 上安装 runipy,我需要 python。但是当我想运行 .gitlab-ci.yml 脚本时,它会卡在打印 python 版本上,因为 python 无法识别。
.gitlab-ci.yml:
image: python:3.9
before_script:
- python -V
- pip install runipy
Run Code Online (Sandbox Code Playgroud)
错误:
Running with gitlab-runner 13.3.1 (738bbe5a)
on JavaUnitTestRunner vr_SgzNd
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:01
Running on DESKTOP-DJVC49J...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Gitlab-Runner/builds/vr_SgzNd/0/I438220/pharma/.git/
Checking out 65a225c0 as pipeline...
git-lfs/2.9.2 (GitHub; windows amd64; go …Run Code Online (Sandbox Code Playgroud) 您好,Gitlab 管道具有多个阶段。我想在 Nodejs 容器中构建一个 React 项目,然后创建另一个带有 nginx 的 docker 容器以在 AWS 上部署。
这是我的 gitlab-ci.yml 文件:
image:
name: node:14-alpine
cache:
key: '$CI_COMMIT_REF_SLUG'
paths:
- node_modules/
- .yarn
stages:
- install
- build
- deploy
job_install:
stage: install
script:
- echo 'yarn-offline-mirror ".yarn-cache/"' >> .yarnrc
- echo 'yarn-offline-mirror-pruning true' >> .yarnrc
- yarn install
cache:
key:
files:
- yarn.lock
paths:
- .yarn-cache/
tags:
- docker
job_build:
stage: build
cache:
key: '$CI_COMMIT_REF_SLUG'
paths:
- node_modules/
- .yarn
script:
- yarn build
artifacts:
paths: …Run Code Online (Sandbox Code Playgroud) 我有以下内容
\nstages:\n - stage1\n - stage2\nvariables:\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0 MY_ENV_VAR:\xc2\xa0env_$CI_JOB_ID\nstage1_build:\n stage: stage1\n script:\n - echo $MY_ENV_VAR\nstage2_build:\n stage: stage2\n script:\n - echo $MY_ENV_VAR\nRun Code Online (Sandbox Code Playgroud)\n$MY_ENV_VAR我在两个阶段得到不同的值(这意味着$CI_JOB_ID每个阶段都有变化)。
我想要的是设置$MY_ENV_VAR一次 的一个值$CI_JOB_ID并将其设为常量,以便$MY_ENV_VAR在所有阶段使用相同的值。
以下是我设置自定义 Gitlab 运行程序所遵循的步骤:
按照此处的说明安装 Gitlab 运行程序:https ://docs.gitlab.com/runner/install/linux-repository.html
使用dockerexetuor 和docker:19image注册一个 runner
写gitlab-ci.yml如下:
image: docker:19.03.1
services:
- name: docker:19.03.1-dind
alias: docker
stages:
- build
build:
stage: build
variables:
IMAGE_TAG: repo.azurecr.io/some-repo
DOCKER_HOST: tcp://172.17.0.1:2375
DOCKER_TLS_CERTDIR: ''
script:
- docker login someacr.azurecr.io -u "$SERVICE_PRINCIPAL_USER" -p "$SERVICE_PRINCIPAL_PASSWORD"
- if [[ "$CI_COMMIT_REF_NAME" == "develop" ]]; then docker build -t $IMAGE_TAG .; fi
Run Code Online (Sandbox Code Playgroud)
Login succeeded
if [[ "$CI_COMMIT_REF_NAME" == "develop" ]]; then docker build -t $IMAGE_TAG .; fi
Cannot connect …Run Code Online (Sandbox Code Playgroud)