我在我的项目中使用 Gitlab CI。当我推送开发分支时,它会运行测试并更新我的测试环境(远程服务器)上的代码。
但是 gitlab runner 已经在使用相同的构建文件夹: builds/a3ac64e9/0/myproject/myproject
但我想每次都创建一个 now 文件夹:
builds/a3ac64e9/1/yproject/myprojectbuilds/a3ac64e9/2/yproject/myprojectbuilds/a3ac64e9/3/yproject/myproject使用它,我可以通过更改指向最后一个运行器目录的符号链接来更新我的网站。
有没有办法以这种方式配置 Gitlab Runner?
我正在使用 .gitlab 测试 GitLab CI 管道gitlab-runner exec。在执行脚本期间,Boost 遇到错误,并创建了一个日志文件。我想查看此日志文件,但我不知道如何查看。
.gitlab-ci.yml 在项目目录中:
image: alpine
variables:
GIT_SUBMODULE_STRATEGY: recursive
build:
script:
- apk add cmake
- cd include/boost
- sh bootstrap.sh
Run Code Online (Sandbox Code Playgroud)
我在我的机器上测试这个:
sudo gitlab-runner exec docker build --timeout 3600
Run Code Online (Sandbox Code Playgroud)
输出的最后几行:
Building Boost.Build engine with toolset ...
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
ERROR: Job failed: exit code 1
FATAL: exit code 1
Run Code Online (Sandbox Code Playgroud)
bootstrap.log 是我想看的。
追加- cat bootstrap.log到.gitlab-ci.yml不会输出文件内容,因为运行程序在此行之前退出。我尝试使用 来查看过去的容器sudo docker ps -a,但这并没有显示 …
我想用 2 个作业运行 CI pipline:
是否可以?
我正在尝试使用 GitLab CI 设置持续集成/部署管道,并且我正在努力理解(并且没有真正在文档中找到任何信息)关于 GitLab Runner 应该实际居住的位置。我应该在本地机器上运行一个吗?是否应该有一个仅托管 Runner 的服务器?
根据我的理解,runner 的目的是执行由提交触发的作业。提交后,GitLab Runner 将尝试执行 .gitlab-ci.yml 文件中定义的作业。
我知道这些作业可以做很多事情,但作为一个起点,我只想通过 SSH 连接到服务器,然后部署我的代码。
我的困惑来自于不明白 Runner 应该实际生活和运行的推荐地点是什么?将它存储在我的本地机器上似乎可能有问题,因为这将依赖于我的机器正在运行并且可用于部署工作。这是否意味着我们需要另一台服务器仅用于运行程序本身?
I recently wanted to move a Gitlab runner that I had set up for my self-hosted Gitlab instance from being a project runner (i.e. running jobs only for a project) to being a group runner (so it could also run jobs for other projects in the same group). I wanted to retain the /etc/gitlab-runner/config.toml settings that I had painstakingly hand-written.
Luckily I backed up config.toml, because sudo gitlab-runner unregister -t ... -u ... deleted the whole configuration from config.toml …
我正在使用 gitlab runner 在本地测试我的 CI。
我运行它:
sudo gitlab-runner exec docker godep --docker-privileged
Run Code Online (Sandbox Code Playgroud)
godep 是我需要运行的工作
现在,下一步是gobuild,但这一步依赖于上一步,因为它将生成一个工件
是否可以使用 gitlab-runner 运行多个作业???
我正在尝试使用curl. 这是我尝试过的。
首先,获取最后一个管道 ID:
curl -v -H "Content-Type: application/json" -H "PRIVATE-TOKEN: <my-token-here>" https://<project>/api/v4/projects/<project>/pipelines?per_page=1&page=1
Run Code Online (Sandbox Code Playgroud)
接下来,根据之前刚刚获取的管道 id 获取作业 id:
curl -sS --header "PRIVATE-TOKEN: <my-token-here>" "https://[redacted,host]/api/v4/projects/[redacted,project]/pipelines/<pipeline-id>/jobs" | jq '.[] | select(.name == "build-assets" and .status == "success" and .artifacts_file != null) | .id'
Run Code Online (Sandbox Code Playgroud)
最后,build.zip根据作业 ID获取工件:
curl -sS --header "PRIVATE-TOKEN: <my-token-here>" "https://[redacted,host]/api/v4/projects/[redacted, project]/jobs/<JOB_ID>/artifacts" > build.zip
Run Code Online (Sandbox Code Playgroud)
上面的这些步骤确实有效,但我必须点击三个端点(并为每个步骤处理 JSON 响应)。
我也读GitLab的文档,这有一个单一的可用于该端点。所以我也试过这个:
curl -sS --header "PRIVATE-TOKEN: <my-token-here>" "https://<url>/<namespace>/<project>/-/jobs/artifacts/<refs>/download?job=<job_name>"
Run Code Online (Sandbox Code Playgroud)
但这总是将我重定向到登录页面,说:
curl -v -H "Content-Type: application/json" -H "PRIVATE-TOKEN: <my-token-here>" https://<project>/api/v4/projects/<project>/pipelines?per_page=1&page=1
Run Code Online (Sandbox Code Playgroud)
有没有更简单的方法来完成这项任务?或者如何正确使用上述文档中描述的端点?
我正在尝试使用 gitlab ci runner 将我的 Flask 应用程序部署到 AWS EC2 实例。
.gitlab.ci.yml
stages:
- test
- deploy
test_app:
image: python:latest
stage: test
before_script:
- python -V
- pip install virtualenv
- virtualenv env
- source env/bin/activate
- pip install flask
script:
- cd flask-ci-cd
- python test.py
prod-deploy:
stage: deploy
only:
- master # Run this job only on changes for stage branch
before_script:
- mkdir -p ~/.ssh
- echo -e "$RSA_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- '[[ -f …Run Code Online (Sandbox Code Playgroud) 当我尝试运行管道时出现以下错误
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
这与 gitlab-runner 权限有关吗?我已尝试授予其完全访问权限,但仍然失败。有人可以帮我吗?
我正在遵循 gitlab 上提到的指南 https://docs.gitlab.com/runner/install/linux-manually.html
Gitlab Runner 版本:13.4.1 Git 修订版:e95f89a0 Git 分支:13-4-stable GO 版本:go1.13.8 内置:2020-09-25T20:03:43+0000 OS/Arch:linux/amd64
Ubuntu 发行商 ID:Ubuntu 描述:Ubuntu 20.04.1 LTS 版本:20.04 代号:focal
gitlab-ci-runner ×10
gitlab ×8
gitlab-ci ×8
amazon-ec2 ×1
bash ×1
curl ×1
deployment ×1
docker ×1
git ×1
ubuntu ×1