Skip to content

GitLab CI/CD

You can use private Capawesome npm packages within your GitLab CI/CD pipelines by configuring the Capawesome npm registry. This guide shows you how to set up authentication to access the private packages from the Capawesome Insiders program.

Preparation

Create a GitLab CI/CD Variable

Get your license key and add it to your GitLab project as a CI/CD variable with the name CAPAWESOME_NPM_REGISTRY_TOKEN as described in CI/CD variables. Make sure to mark the variable as masked and protected.

Keep your license key secure

Never commit your license key directly to your repository and always use environment variables to store sensitive information like authentication tokens.

Pipeline Configuration

Configure the npm registry

Add the following script to your GitLab CI/CD pipeline before installing npm dependencies:

before_script:
  - echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc
  - echo "//npm.registry.capawesome.io/:_authToken=${CAPAWESOME_NPM_REGISTRY_TOKEN}" >> .npmrc

This will automatically configure npm to use the Capawesome registry for @capawesome-team packages during GitLab CI/CD builds.

Example

Here's a complete example of a GitLab CI/CD pipeline that builds an Ionic app using private Capawesome packages:

stages:
  - build

build-app:
  stage: build
  image: node:20
  before_script:
    - echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc
    - echo "//npm.registry.capawesome.io/:_authToken=${CAPAWESOME_NPM_REGISTRY_TOKEN}" >> .npmrc
    - npm ci
  script:
    - npx cap sync
    - npm run build
  artifacts:
    paths:
      - dist/
    expire_in: 1 hour
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

This pipeline will authenticate with the Capawesome npm registry and install any private packages specified in your package.json file.