我正在尝试使用 gitlab CI 构建和测试 .NET 项目。
我已经下载并安装了最新版本的 GitLab runner,并成功地将它注册到了我们的 gitlab 实例。我创建了以下.gitlab-ci.yaml文件:
variables:
Solution: Performance-Validation-Tool.sln
stages:
- build
- test
# - deploy
build:
stage: build
script:
- echo "Restoring NuGet packages..."
- 'C:/nuget/NuGet.exe restore'
- echo building...
- 'msbuild.exe "%Solution%"'
except:
- tags
test:
stage: test
script:
- echo testing...
- 'msbuild.exe "%Solution%"'
- dir /s /b *.Tests.dll | findstr /r Tests\\*\\bin\\ > testcontainers.txt
- 'for /f %%f in (testcontainers.txt) do mstest.exe /testcontainer:"%%f"'
except:
- tags
Run Code Online (Sandbox Code Playgroud)
重要的部分是构建操作。
如果我从 …
continuous-integration nuget gitlab gitlab-ci gitlab-ci-runner
我正在使用 gitlab CI 将工件部署到我团队的 maven 存储库,但我很难设置 maven 凭据。
我不想将它们放在 settings.xml 文件中,因为 CI runner 被其他具有不同存储库的团队使用,我想保持我们的存储库不受其他工件的影响。
我怎样才能以不同的方式做到这一点?我正在考虑使用 maven 参数或 POM 文件以及 CI 变量。
我的 Gitlab 管道设置存在以下问题。
我认识到在 bash 中显示了“shell runner”,但在 .yml 文件中我使用了“标签:-docker”。如果我重新运行该作业,有时它会起作用并使用正确的运行器,但大多数时候不会。
这是 bash 输出:
Running with gitlab-runner 10.8.0 (079cad9e)
on aws-xyz c444133a
Using Shell executor...
Running on ip-xyz...
Fetching changes...
HEAD is now at eb4ea13 xyz: removed data retry queue
Checking out e0461c05 as backend-tests...
Skipping Git submodules setup
Checking cache for default-1...
Successfully extracted cache
$ echo "this is done BEFORE each step"
this is done BEFORE each step
$ echo "updating server software inside container"
updating server software inside container …
我有一个关于 Gitlab CI 的非常不寻常的用例,但我找不到满足我需求的解决方案。
我有一个 Gitlab 存储库,它使用其他存储库共享的子模块。我想实现一个运行器来为这个应用程序构建一个 Docker 容器镜像。为此,我按如下方式配置了我的 ci(使用 docker-in-docker 方法):
image: docker:stable
variables:
# When using dind service we need to instruct docker, to talk with the
# daemon started inside of the service. The daemon is available with
# a network connection instead of the default /var/run/docker.sock socket.
#
# The 'docker' hostname is the alias of the service container as described at
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services
#
# Note that if you're using Kubernetes executor, the variable should …Run Code Online (Sandbox Code Playgroud) 所以我们的 GitLab Runner 已经运行了几个星期了。我不得不进行一些升级,需要在安装它的机器上重新启动。
重新启动后,它不再自动获取作业。我所有的管道都说它们被卡住了,因为没有跑步者可以接手工作。
我 SSH 进入机器并运行
sudo gitlab-runner run
Run Code Online (Sandbox Code Playgroud)
并且工作会按照我的预期进行。但是,当我按CTRL+ 时,C它会停止任何已接的工作并再次停止接任何其他工作。如何解决此问题,使其恢复到重新启动前的状态?
当我跑
sudo gitlab-runner start
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息: FATAL: Failed to start gitlab-runner: "systemctl" failed: exit status 5, Failed to start gitlab-runner.service: Unit gitlab-runner.service not found.
我跑的时候也弹出类似的错误
sudo gitlab-runner restart
Run Code Online (Sandbox Code Playgroud) 我查看了任何其他问题,但找不到自己的解决方案!我在 gitlab 中设置了一个 CI 并使用了 gitlab 的共享运行程序。在构建阶段,我使用 docker 镜像作为基础镜像,但是当我使用docker命令时,它说:
无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。docker 守护进程是否正在运行?
我看了这个话题,但还是不明白我该怎么办?
.gitlab-ci.yml :
stages:
- test
- build
- deploy
job_1:
image: python:3.6
stage: test
script:
- sh ./sh_script/install.sh
- python manage.py test -k
job_2:
image: docker:stable
stage: build
before_script:
- docker info
script:
- docker build -t my-docker-image .
Run Code Online (Sandbox Code Playgroud)
我知道 gitlab runner 必须注册才能使用docker和分享/var/run/docker.sock!但是在使用 gitlab 自带的 runner 时怎么做呢?
我为 Gitlab-CI 配置了一个非常基本的集成,但是当它必须克隆代码时,它几乎在一开始就失败了。
我的整合是这样的:
image: node:latest
stages:
- build
- test
cache:
paths:
- node_modules/
- dist/
build-prod:
stage: build
script:
- npm install
- npm run build-prod
artifacts:
paths:
- node_modules/
- dist/
test_with_karma:
stage: test
script: ng test
Run Code Online (Sandbox Code Playgroud)
我得到的错误是这样的:
Running with gitlab-runner 11.7.0 (8bb608ff)
on fakehost 2eaf11ea
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:8c67bfd7b95bdc535edc4a4144f5392b0f73efd6385fbcb47747d028d7059359 for node:latest ...
Running on runner-2eaf11ea-project-56-concurrent-0 via fakehost...
Cloning repository...
Cloning into '/builds/redacted/frontend'...
remote: You …Run Code Online (Sandbox Code Playgroud) 我正在使用单个 macOS GitLab 运行程序来执行 iOS 作业。runner 已成功与 GitLab 配对并接收作业,但是,作业立即失败并且 runner 向 GitLab 报告。
通过查看运行器日志,我无法追踪问题,即使在--debug模式下运行 GitLab Runner 也是如此。
问题:
GitLab 网页界面上的工作报告:
Running with gitlab-runner 11.7.0 (8cc638ff)
on iMac 8cc638ff
Using Shell executor...
Running on name-iMac.local...
Fetching changes...
ERROR: Job failed: exit status 1
Run Code Online (Sandbox Code Playgroud)
gitlab-runner --debug run命令的输出:
Checking for jobs... received job=216 repo_url=https://gitlab.local/software/ios.git runner=00000000
Failed to requeue the runner: builds=1 runner=00000000
Running with gitlab-runner 11.7.0 (8bb608ff) job=216 project=34 runner=00000000
on iMac 00000000 job=216 project=34 runner=00000000
Shell configuration: …Run Code Online (Sandbox Code Playgroud) 我有这个 .gitlab-ci.yml 文件:
stepA:
script:
- echo "A"
deploy:
script:
- echo "1"
stepB:
script:
- echo "B"
Run Code Online (Sandbox Code Playgroud)
如何设置应该首先运行哪个阶段?一些作业可以由多个 gitlab runner 并行运行。我只想确保在运行部署阶段之前完成步骤 A 到 B
ERROR: Job failed: build directory needs to be an absolute path
Run Code Online (Sandbox Code Playgroud)
这是.gitlab-ci.yml:
image: busybox:latest
before_script:
- echo "Before script section"
- echo "For example you might run an update here or install a build dependency"
- echo "Or perhaps you might print out some debugging details"
after_script:
- echo "After script section"
- echo "For example you might do some cleanup here"
build1: …Run Code Online (Sandbox Code Playgroud)