gitlab-dynamic-pipelines
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

gitlab-dynamic-pipelines

Package for creating dynamic Gitlab CI/CD pipelines in TypeScript. Helpful if you want to create TypeScript objects that follow the GitLab CI/CD YAML Syntax Reference using TypeScript types.

Installation

npm install gitlab-dynamic-pipelines

Usage

Use these types to build a basic pipeline like this:

import { writeFileSync } from 'node:fs';
import { toYAML, Pipeline } from 'gitlab-dynamic-pipelines';

const pipeline: Pipeline = {
  globalKeywords: {
    workflow: {
      name: 'Basic Pipeline',
    },
    stages: ['test', 'build'],
    default: {
      image: 'node:18',
    },
  },
  jobs: {
    job1: {
      stage: 'test',
      image: 'node:20.12.2',
      script: ['echo "it works!'],
    },
    job2: {
      stage: 'build',
      script: ['echo "it has been built!'],
    },
  },
};

writeFileSync('.gitlab-ci.yml', toYAML(pipeline));

Why are globalKeywords and jobs separated into two different sub-objects?

This is a limitation of TypeScript. As of this version, there is no way to define a type that has both known and unknown keys.

Readme

Keywords

Package Sidebar

Install

npm i gitlab-dynamic-pipelines

Weekly Downloads

723

Version

0.4.2

License

MIT

Unpacked Size

13.4 kB

Total Files

23

Last publish

Collaborators

  • onlywei