Help! Is GitLab CI/CD Serverless deploy possible?

I can not get Serverless deploy to work with GitLab CI/CD

Has anyone had success with deploying Serverless from GitLab CI/CD ?

hi ajoslin103,

I have done this so that every time new code is pushed to gitlab, a pipeline runs that deploys to my test environment. Just make sure that you include serverless as a dependency of your project

npm i serverless --save

then add the following to your .gitlab-ci. In my example, I cache all node_modules so I don’t have to install them for every stage of my pipeline. And in the stage definition (deploy-test), I call upon the locally installed version of serverless.

image: node:latest
  
stages:
  - deploy

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm/

before_script:
  - npm config set prefix /usr/local
  - npm ci --cache .npm --prefer-offline

deploy-test:
  stage: deploy
  script:
    - ./node_modules/.bin/serverless deploy
  environment: test

Hope this helps!

1 Like

I found a project to clone that worked

Apologies - I should have returned and marked this solved

no worries, glad it worked out for you