Issue
I have a simple CI/CD setup for my GitLab repo.
During the build
job, the commands install NPM, run a build script which uses Webpack to build the JS/SCSS etc.
Then, since I don't want any of the source files to be uploaded to my server, I remove them along with some other files that are not needed for deployment.
However, when the parent directory htdocs
is uploaded as an artifact so it can be used in the deploy job, when I run ls -la
and ls ./assets -la
in the deploy
job, I can still see all of the files that I removed earlier in the build
job.
When I download the artifact ZIP file from the browser, everything is correct as all of my unneeded files are gone.
Why is it then I can still see BOTH the source and distributed files in the build
job? Is this a bug?
At the moment this is causing all of my source files to be uploaded to my server which is not what I want. Can anyone help?
image: node:11.9.0
before_script:
- cd ./htdocs
stages:
- build
- deploy
build:
stage: build
script:
- npm install --quiet
- npm run build
- rm -rf node_modules assets/src
- rm -r .??* package.json package-lock.json README.md webpack.*.js
artifacts:
paths:
- ./htdocs/
deploy:
stage: deploy
cache: {}
dependencies:
- build
script:
- ls -la
- ls ./assets/ -la
Solution
Every job in GitLab by default clones the repository and then downloads any artifacts you set in the dependencies. You should see this at the start of the job log of the deploy
stage.
To stop your source files from being uploaded in your deploy stage, you could set the GIT_STRATEGY to none
.
Eg:
deploy:
stage: deploy
cache: {}
variables:
GIT_STRATEGY: none
dependencies:
- build
script:
- ls -la
- ls ./assets/ -la
Answered By - Rekovni Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.