2
.deploy: &deploy
  before_script:
    - apt-get update -y
  script:
    - cd source/
    - npm install multi-file-swagger
    - multi-file-swagger -o yaml temp.yml > swagger.yml

I want to install multi-file-swagger package to compile the temp.yml( which has been split into multiple files) into the swagger.yml. So before using npm I need to install nodejs. How can I do that?

5
  • Which base image are you using? Can you please post the complete gitlab-ci.yml? Commented Jan 13, 2022 at 7:06
  • I am using this as base image : mcr.microsoft.com/dotnet/core/sdk:3.1 Commented Jan 13, 2022 at 7:12
  • This is a Debian-based runtime, right? Or is it Alpine? Commented Jan 13, 2022 at 7:25
  • It is Debian-based Commented Jan 13, 2022 at 7:41
  • Right, I missed the apt-get update in the third line. Commented Jan 13, 2022 at 8:26

1 Answer 1

4

As the image is Debian-based, you should be able to install the source repo from Node and install the package from there. The relevant section of your Gitlab file would look like this:

.deploy: &deploy
  before_script:
    - apt-get update -y
  script:
    - curl -sL https://deb.nodesource.com/setup_17.x | bash
    - apt-get install nodejs -yq
    - cd source/
    - npm install multi-file-swagger
    - multi-file-swagger -o yaml temp.yml > swagger.yml

Please note that these additional steps will add a significant amount of time to your build process. If you are executing them more frequently, consider creating your own build image derived from the one you’re using now, and adding these steps into the image itself.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it is working, also how to install it on python:3.7-slim as I have another job that uses the python image and I need the swagger file in this one too

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.