continuous-integration - 使用 ci/cd 命令行在 gitlab 中提取或解压缩文件
问题描述
实际上,我在 gitlab 上有我的 zip 文件,我想使用 gitlab CI/CD 提取这些文件。我在 .gitlab-ci.yml 中尝试过这个:
image: docker
stages:
- build
- test
services:
- docker:dind
build:
before_script:
- apk add p7zip
script:
- cd \kmfs
- 7z x -oChassisA ChassisA.zip
输出
$ apk add p7zip
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/3) Installing libgcc (6.4.0-r9)
(2/3) Installing libstdc++ (6.4.0-r9)
(3/3) Installing p7zip (16.02-r3)
Executing busybox-1.28.4-r3.trigger
OK: 11 MiB in 17 packages
$ cd \kmfs
$ 7z x -oChassisA ChassisA.zip
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Xeon(R) CPU @ 2.30GHz (306F0),ASM,AES-NI)
Scanning the drive for archives:
1 file, 3638943 bytes (3554 KiB)
Extracting archive: ChassisA.zip
--
Path = ChassisA.zip
Type = zip
Physical Size = 3638943
Everything is Ok
Folders: 1
Files: 4
Size: 24070952
Compressed: 3638943
Job succeeded
它执行成功,但提取的文件未反映在 gitlab 存储库中,我无法使用在测试阶段编写的节点 js 代码访问这些文件。
因此,如果有人建议我使用命令或从 nodejs 代码中提取 gitlab 本身的 .zip 文件,那就太好了...
解决方案
您需要使用工件作为工作的一部分来声明提取的 zip 的路径。这将允许后续作业访问这些文件。
artifacts:
when: always
expire_in: 1 week
paths:
- zip files folder structure after its extracted
推荐阅读
- dart - 如何在 Dart 中将变量转换为泛型类型?
- typescript - 使用 TypeScript 将带有 Chai 的 WebdriverIO 配置为全局变量
- php - 从多个表中删除问题
- javascript - 从画布获取图像数据作为文本的最快方法
- c++ - 在 C++ 中使用 strncpy() 需要帮助
- office-js - Outlook 的 Office 加载项 - 附加 .msg 文件会导致文件大小为 0
- python - 如何将变量从一个类调用到另一个类?
- python - Pandas:按升序对每组的行数进行排序
- c# - 大型测试用例集的 Nunit 测试运行被冻结
- linux - 在 Raspbian Buster、Raspberry Pi 4 中重新启动时有时未加载蓝牙模块