This is for an Angular project I have.
The project itself builds and runs just fine. I have just been struggling with trying to figure out how to make my 1st CI/CD pipeline process gitlab-ci.yml file. This has been going on for months.
How the heck is this to be setup because I cannot find a basic example that just works.
image: node:14.17.0
stages: # List of stages for jobs, and their order of execution
- setup
- build
- cleanup
.pre:
stage: setup,
script:
- mkdir -p dist
- npm install -g @angular/cli@12.2.16
- npm install # or `npm install` or whatever you use to install deps
- npm start
- npm --version
cache:
paths:
- node_modules
policy: pull
build-job:
stage: build
script: # ... your other build steps here
- npm run build_def_mysetup
- ls /builds
cache:
paths:
- node_modules
policy: pull
artifacts:
paths:
- dist/
.post:
stage: cleanup
script:
- echo "cleanup called"
The goal right now for this is to
I say eventually because I cannot get #1 to work
Alright, i had a quick glance at your pipeline and tried it on an angular project.
First, by following the gitlab-ci documentation, you should not mix stages, with .pre
and .post
. please take a look at Gitlab CI stages, in this matter.
Next, for the matter of artifacts, you do not need to specifically set path to artifacts, as they are kept between subsequent stages.
Now for the pipeline
-
Install dependencies - node_modules
stage: install_dependencies
image: node:14
script:
- npm install
Install angular
stage: install_angular
image: node:14
script:
- npm install -D typescript @angular/cli @angular/compiler
Build angular app
stage: build
image: node:14
script:
- npm run build
Notify if the build fails
Run unit tests + release
The full pipeline would look something like this (its a trivial example, it can be merged into one stage)
image: node:14.17.0
stages: # List of stages for jobs, and their order of execution
- install_dependencies
- install_angular
- build
install_dep:
stage: install_dependencies
image: node:14
script:
- npm install
install_ang:
stage: install_angular
image: node:14
script:
- npm install -D typescript @angular/cli @angular/compiler
build_ang:
stage: build
image: node:14
script:
- npm run build