Integrate DepAegis into your GitLab CI/CD pipelines to publish npm packages, NuGet packages, and Docker images automatically on tags and merges.
Store your DepAegis Personal Access Token as a CI/CD variable in GitLab:
DEPAEGIS_TOKEN, paste the token as the value, and enable Mask variable and Protect variable.Add a publish stage to your .gitlab-ci.yml that runs on version tags:
# .gitlab-ci.yml
stages:
- test
- publish
test:
stage: test
image: node:20
script:
- npm ci
- npm test
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_MERGE_REQUEST_IID'
publish-npm:
stage: publish
image: node:20
script:
- npm ci
- npm run build
- |
cat > .npmrc <<EOF
//app.depaegis.com/:_authToken=${DEPAEGIS_TOKEN}
@my-org:registry=https://app.depaegis.com/api/v1/npm/
EOF
- npm publish
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+/'.npmrc is written at build time from the CI variable. Never commit .npmrc files containing tokens to the repository.Build and push .NET packages using the dotnet CLI:
# .gitlab-ci.yml
stages:
- test
- publish
test:
stage: test
image: mcr.microsoft.com/dotnet/sdk:10.0
script:
- dotnet test
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_MERGE_REQUEST_IID'
publish-nuget:
stage: publish
image: mcr.microsoft.com/dotnet/sdk:10.0
script:
- dotnet pack MyPackage.csproj -c Release -o ./artifacts
- |
dotnet nuget push ./artifacts/*.nupkg \
--source "https://nuget.app.depaegis.com/api/v1/nuget/v3/index.json" \
--api-key "$DEPAEGIS_TOKEN" \
--skip-duplicate
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+/'Build and push container images using Docker-in-Docker:
# .gitlab-ci.yml
stages:
- publish
publish-docker:
stage: publish
image: docker:27
services:
- docker:27-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- echo "$DEPAEGIS_TOKEN" | docker login app.depaegis.com -u "$CI_REGISTRY_USER" --password-stdin
script:
- docker build -t app.depaegis.com/my-org/my-app:$CI_COMMIT_TAG .
- docker tag app.depaegis.com/my-org/my-app:$CI_COMMIT_TAG app.depaegis.com/my-org/my-app:latest
- docker push app.depaegis.com/my-org/my-app:$CI_COMMIT_TAG
- docker push app.depaegis.com/my-org/my-app:latest
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+/'$CI_REGISTRY_USER with your actual DepAegis username, or use a service account name. The password is the DEPAEGIS_TOKEN.A combined pipeline with test, npm publish, NuGet publish, and Docker publish stages:
# .gitlab-ci.yml
stages:
- test
- publish
variables:
NPM_REGISTRY: "https://app.depaegis.com/"
NUGET_SOURCE: "https://nuget.app.depaegis.com/api/v1/nuget/v3/index.json"
DOCKER_REGISTRY: "app.depaegis.com"
# ── Test ────────────────────────────────────────────────
test-node:
stage: test
image: node:20
script:
- npm ci
- npm test
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_MERGE_REQUEST_IID'
test-dotnet:
stage: test
image: mcr.microsoft.com/dotnet/sdk:10.0
script:
- dotnet test
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_MERGE_REQUEST_IID'
# ── Publish ─────────────────────────────────────────────
publish-npm:
stage: publish
image: node:20
needs: [test-node]
script:
- npm ci
- npm run build
- |
cat > .npmrc <<EOF
//app.depaegis.com/:_authToken=${DEPAEGIS_TOKEN}
@my-org:registry=https://app.depaegis.com/api/v1/npm/
EOF
- npm publish
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+/'
publish-nuget:
stage: publish
image: mcr.microsoft.com/dotnet/sdk:10.0
needs: [test-dotnet]
script:
- dotnet pack MyPackage.csproj -c Release -o ./artifacts
- dotnet nuget push ./artifacts/*.nupkg --source "$NUGET_SOURCE" --api-key "$DEPAEGIS_TOKEN" --skip-duplicate
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+/'
publish-docker:
stage: publish
image: docker:27
services:
- docker:27-dind
needs: [test-node]
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- echo "$DEPAEGIS_TOKEN" | docker login $DOCKER_REGISTRY -u gitlab-ci --password-stdin
script:
- docker build -t $DOCKER_REGISTRY/my-org/my-app:$CI_COMMIT_TAG .
- docker push $DOCKER_REGISTRY/my-org/my-app:$CI_COMMIT_TAG
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+/'Speed up pipelines by caching package downloads between runs. GitLab CI supports cache directives per job.
# Add to any Node.js job
cache:
key:
files:
- package-lock.json
paths:
- node_modules/
script:
- npm ci # uses cache if available# Add to any .NET job
cache:
key:
files:
- MyPackage.csproj
paths:
- ~/.nuget/packages/
script:
- dotnet restore # uses cache if available# Use BuildKit cache with a local mount
variables:
DOCKER_BUILDKIT: "1"
script:
- |
docker build --cache-from type=local,src=/cache --cache-to type=local,dest=/cache,mode=max -t app.depaegis.com/my-org/my-app:$CI_COMMIT_TAG .
cache:
key: docker-build-cache
paths:
- /cache/