我有一个独立的 Gitlab 服务器和 Gitlab 运行器,它们缺乏互联网连接。我正在尝试在 Docker 容器中运行“语义版本控制”(一个 node.js 应用程序),以便它可以处理我的 GitLab 存储库的自动版本控制。
我必须提前将所有依赖项构建到 Docker 容器中,因为它们在运行时无法访问 Internet,并且我必须手动将容器移动到 Gitlab Runner 以进行手动 Docker 加载。
我已经解决了所有的令牌问题并将所有部分连接在一起,我终于得到了一个肯定的结果(有一个小版本的碰撞),但是在一个几乎空的存储库上运行需要 1660 秒(这个 repo 只是为了测试) .
占用最多时间和进程挂起的步骤是执行“npx semantic-release”时。从那里完成最多可能需要 40 分钟。但是,一旦 npx 语义发布步骤完成,分析 repo 的实际“工作”只需几秒钟。这让我认为这与 Dockerfile 的准备方式有关,而不是语义发布本身的配置问题。
这是下面花费时间最长的步骤:
$ npx 语义释放
npx:在 1660.75s 内安装了 575
Executing "step_script" stage of the job script
Using docker image sha256:d0733317abd6fbce07dcf85b1aff35d82f986e7de9ff56fdf5b985504bf3e9f4 for semantic:1 ...
$ npx semantic-release
npx: installed 575 in 1660.75s
[6:03:29 PM] [semantic-release] › ℹ Running semantic-release version 17.4.4
[6:03:29 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/gitlab"
[6:03:29 PM] [semantic-release] › ✔ Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[6:03:29 PM] [semantic-release] › ✔ Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[6:03:29 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/gitlab"
[6:03:29 PM] [semantic-release] › ✔ Run automated release from branch main on repository http://gitlab-ci-token:[secure]@[internal_IP]/gitlab-instance-937dde58/my_second_project.git
[6:03:30 PM] [semantic-release] › ✔ Allowed to push to the Git repository
[6:03:30 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/gitlab"
[6:03:30 PM] [semantic-release] [@semantic-release/gitlab] › ℹ Verify GitLab authentication (http://[internal_IP]/api/v4)
[6:03:30 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[6:03:30 PM] [semantic-release] › ℹ Found git tag v1.0.0 associated with version 1.0.0 on branch main
[6:03:30 PM] [semantic-release] › ℹ Found 32 commits since last release
[6:03:30 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[6:03:30 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: new stuff
可能是我的 Dockerfile 需要进一步检查。但是我对此很陌生,并且需要关于花费这么长时间的建议(我可以不让 dockerfile 提前安装 575 依赖项以进行语义发布吗?)
这是我的 Dockerfile(我构建为“语义:1 ”)
FROM node:13
RUN npm config set strict-ssl false
RUN npm install semantic-release@17.4.4
RUN npm install @semantic-release/gitlab@6.2.2
这是我的 gitlab-ci.yml
---
release:
image: "semantic:1"
only:
refs:
- main
- alpha
- "/^(([0-9]+)\\.)?([0-9]+)\\.x/"
- "/^([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$/"
script:
- "npx semantic-release"
stage: release
stages:
- release
和我的 .releaserc.yml
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/gitlab"
branches:
- "main"
- "+([0-9])?(.{+([0-9]),x}).x"
- name: "alpha"
prerelease: "alpha"
谢谢!