小编Ada*_*all的帖子

Gitlab config.toml 在哪里

我正在致力于向 gitlab 添加代码质量。其中一个步骤需要更改 config.toml。

我在项目存储库的根级别有 .gitlab-ci.yml。并且管道拾取此文件。

我在哪里定义 config.toml ?在根级别,或者我需要创建一个新文件夹,例如 /etc/gitlab-runner/config.toml

gitlab gitlab-ci gitlab-ci-runner gitlab-runner

21
推荐指数
1
解决办法
3万
查看次数

如何使用 GitLab CI/CD 获取整个存储库?

我目前正在设置 GitLab CI/CD。我们在项目中使用GitVersion,会抛出以下错误:

/root/.nuget/packages/gitversiontask/5.3.7/build/GitVersionTask.targets(46,9): error : InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.

根据这篇博客,当 CI 服务器没有获取完整的存储库时(我们有一个开发分支和一个主分支,但我正在开发另一个分支),就会发生这种情况。对于 Jenkins,我们通过扩展结账阶段解决了这个问题:

stage("Checkout") { gitlabCommitStatus(name: "Checkout") {
    
    // These are the normal checkout instructions
    cleanWs()
    checkout scm
    
    // This is the additional checkout to get all branches
    checkout([
      $class: 'GitSCM',
      branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
      extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
      userRemoteConfigs: scm.userRemoteConfigs,
    ])

    sh "git checkout ${env.BRANCH_NAME}"
    sh "git reset --hard origin/${env.BRANCH_NAME}"
}} …
Run Code Online (Sandbox Code Playgroud)

git continuous-integration gitlab gitlab-ci

16
推荐指数
1
解决办法
3万
查看次数

如何在 gitlab ci/cd 中使用自定义变量?

我正在与 gitlab ci/cd 变量作斗争。我看到很多相互矛盾的例子。无论如何,我想知道的是如何在脚本外部和内部使用变量。

例如,在作业配置中,我可以使用 bash 命令在脚本部分分配变量吗?

some-job:
   variables:
      SOME_VAR: ''
   script:
      - SOME_VAR = $(<file_with_a_line_of_text.txt)
Run Code Online (Sandbox Code Playgroud)

在上述情况下,我不确定我是否可以做到这一点。但我需要用文件内容(即工件)填充变量。另外,什么时候在变量前面使用“$”?我看到使用这些格式的一些示例:

"SOME_VAR" #in quotes, no dollar sign
"${SOME_VAR}" #in quotes, with dollar sign and wrapped with curly braces
${SOME_VAR} #no quotes, with dollar sign and wrapped with curly braces
$SOME_VAR #i.e. without the double quotes or curly braces
SOME_VAR #i.e. without the double quotes, dollar sign, and curly braces
Run Code Online (Sandbox Code Playgroud)

我可以在示例中看到如此多的用法变化,但实际上不知道何时使用每种样式。我无法在网上找到使用 bash 命令在脚本中设置自定义变量的示例。

bash shell gitlab gitlab-ci

16
推荐指数
2
解决办法
3万
查看次数

如何设置在 cron 计划中使用本地时间?

Cron 默认使用 UTC 时区。如何将其设置为在 cron 表达式(用于 cron 计划)中使用当地时间(例如 CST)。

cron

9
推荐指数
2
解决办法
1万
查看次数

Gitlab-CI 中存在已删除的标签

我正在使用语义发布进行版本控制。每当我将某些东西推送到我的分支时,CI(Gitlab)就会执行语义发布。我的问题是我推送到我的 git 分支,semantic-release 创建了一个版本并创建了标签(例如 1.0.0)。最后,我发现我错过了这次提交的一些重要内容。所以我删除了Gitlab中的标签(存储库>标签,例如https://gitlab.com/user/project/-/tags),最后再次推送我的提交。但现在,semantic-release 告诉我该标签已经存在,但 Gitlab 不再显示任何标签(我删除了所有标签)。现在我决定将以下行添加到我的 CI 中:

git show-ref --tags -d

这显示了我已经在 Gitlab 中删除的所有标签,但它们似乎存在于我的 CI 中。所以我很困惑这里发生了什么......有什么想法吗?我的 CI 中是否需要“同步标签”之类的东西?

git gitlab gitlab-ci semantic-release

7
推荐指数
1
解决办法
3949
查看次数

在为 GitLab Runner 拉取镜像之前登录 Docker

我已经设置了一个 docker 运行程序,我想在其中运行存储在本地存储库上的映像。我的 /etc/gitlab-runner/config.toml 是

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800


[[runners]]
  name = "Docker runner"
  url = "https://gitlab.str.corp/"
  token = "*secret*"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "gitlab.example.com:4443/docker:19.03.1-dind"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/certs/client", "/cache"]
    shm_size = 0
Run Code Online (Sandbox Code Playgroud)

当我提交作业时,它在运行器上启动,但无法拉取图像:

Running with gitlab-runner 13.4.0 (4e1f20da)
  on Docker runner abcde123

Preparing the "docker" executor
Using Docker executor with image gitlab.example.com:4443/docker:19.03.8-git …
Run Code Online (Sandbox Code Playgroud)

gitlab docker gitlab-ci gitlab-ci-runner

6
推荐指数
1
解决办法
1万
查看次数

如何在我的 gitlab-ci.yml 中包含 script.py?

我正在为我的项目实现 gitlab-ci.yml 。在此 yml 文件中,我需要执行 script.py 文件。这个 script.py 位于不同的项目上,是否有办法包含这个 python 脚本而不将其上传到我的项目?

就像是:

include: 'https://gitlab.com/khalilazennoud3/<project-name>/-/blob/main/script.py
Run Code Online (Sandbox Code Playgroud)

include gitlab gitlab-ci

6
推荐指数
1
解决办法
7179
查看次数

为什么 GitLab Ci 找不到我的缓存文件夹?

我的 GitLab 中运行着一个 CI 作业列表,但缓存未按预期工作:

这就是我的文档生成工作的结束方式:

[09:19:33] Documentation generated in ./documentation/ in 4.397 seconds using gitbook theme
Creating cache angular...
00:02
WARNING: frontend/node_modules: no matching files  
frontend/documentation: found 136 matching files   
No URL provided, cache will be not uploaded to shared cache server. Cache will be stored only locally. 
Created cache
Job succeeded
Run Code Online (Sandbox Code Playgroud)

然后我开始部署作业(到 GitLab Pages),但它失败了,因为它找不到文档文件夹:

$ cp -r frontend/documentation .public/frontend
cp: cannot stat 'frontend/documentation': No such file or directory
Run Code Online (Sandbox Code Playgroud)

这是这一代的缓存配置:

generate_docu_frontend:
  image: node:12.19.0
  stage: build
  cache:
    key: angular
    paths: …
Run Code Online (Sandbox Code Playgroud)

yaml gitlab gitlab-ci

6
推荐指数
1
解决办法
6318
查看次数

Gitlab 自动分配合并请求的审阅者

我之前的项目一直在使用GitHub,并且我有所谓的自动分配审阅者来处理拉取请求,它会自动从我的团队中分配审阅者来进行代码审阅。

现在我正在开发一个在Gitlab托管的项目,我想问 gitlab 是否支持合并请求的此功能,或者 gitlab 上是否有此功能的替代方案。

我已经检查了审稿人轮盘赌和危险,但还不清楚,而且我找不到任何有关如何实现它的文档。

提前致谢。

gitlab gitlab-ce

6
推荐指数
2
解决办法
1万
查看次数

如何将 std 错误重定向到 GitLab 运行程序中的 std out

我正在研究GitLab CI/CD并且我知道如何在正常情况下将标准错误重定向到标准输出。就是使用2>&1or >/dev/null 2>&1

有时,我需要一些引发错误的命令,但这些错误并不严重。例如,当我部署 docker 应用程序时,我想停止旧容器(如果存在)并忽略容器不存在时将发生的错误。在这种情况下,我只想忽略标准错误并保留进程进行部署。当我使用 时AWS CodeDeploy,错误重定向2>&1确实有效,但在 中GitLab CI/CD,它不起作用。

下图是取消 CI/CD 进程的错误。如果没有命令停止不存在的容器,则不会出现错误并且部署确实可以工作。

问题。

如何将 std 错误重定向到 std out 或忽略错误并保持部署GitLab CI/CD

在此输入图像描述

在此输入图像描述

continuous-integration gitlab gitlab-ci gitlab-ci-runner

5
推荐指数
1
解决办法
3047
查看次数

如何定期运行gitlab stage?

如何定期运行 gitlab 阶段?我知道此处记录的管道时间表: https: //docs.gitlab.com/ee/ci/pipelines/schedules.html。我只对运行分支的特定测试阶段感兴趣。问题是我想要定位的分支还涉及很多其他阶段。一种选择可能是在脚本部分引入一个变量,该变量表示如果为 true,则执行脚本。然而,这可能很麻烦,并且需要对所考虑的特定分支的 ci 文件的所有阶段进行大量更改。

continuous-integration gitlab gitlab-ci

5
推荐指数
1
解决办法
3058
查看次数

当 2 个测试用例失败时,Gitab CI 管道中的测试标记为通过

我们有一个在 Gitlab 中管理的项目,带有用于构建和测试(pytest、Google 测试)的 CI 管道。我们在 Google 测试中的两三个测试用例失败了。但Gitlab认为测试阶段是成功的。是因为成功率超过90%(任意值)吗?如果我们没有获得 100% 的成功,有没有办法让阶段(以及整个管道)失败?

这是管道摘要的屏幕截图: 在此输入图像描述

这是该阶段的 yml 脚本:

test_unit_test:
  stage: test
  needs: ["build", "build_unit_test"]
  image: $DOCKER_IMAGE
  rules:
    - if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  script: |
    ZIPNAME=`cat _VERSION_.txt`
    ./scripts/gitlab-ci/stage-unittests.sh test_unit_test_report.xml $ZIPNAME
  artifacts:
    reports:
      junit: test_unit_test_report.xml
    expire_in: 1 week
Run Code Online (Sandbox Code Playgroud)

感谢您的任何帮助。问候。

testing unit-testing gitlab gitlab-ci

3
推荐指数
1
解决办法
2993
查看次数