In Gitlab, is there a way with CI/CD or another trick to generate a .zip package with chosen folders after each commit? A script to use in CI/CD ?
I know we can download a whole repository with the button "download source code" but I need to create a package .zip with only some folders of the repository.
Thanks :).
You can either generate a artifact or publish the file as a generic package.
empaquetar:
image: alpine
before_script:
- apk add --update zip
script:
- zip -r content.zip folder1 folder2
artifacts:
paths:
- content.zip
when: on_success
empaquetar:
image: alpine
before_script:
- apk add --update zip curl
script:
- zip -r content.zip folder1 folder2
- 'curl
--header "JOB-TOKEN: $CI_JOB_TOKEN"
--upload-file content.zip
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/Content/1.0.0/content.zip"'
Where Content
in generic/Content/1.0.0
is the package name and 1.0.0
the version.
You can also use $CI_COMMIT_TAG
variable as version if the pipeline executes only on tagged branch with a condition like this:
empaquetar:
image: alpine
script:
- zip -r content.zip folder1 folder2
- 'curl
--header "JOB-TOKEN: $CI_JOB_TOKEN"
--upload-file content.zip
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/Content/${CI_COMMIT_TAG}/content.zip"'
only:
variables:
- $CI_COMMIT_TAG =~ /^\d+.\d+.\d+*$/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With