New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gitlab-yml

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitlab-yml

Create GitLab CI pipelines with TypeScript.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

gitlab-yml

Usage

How extends work

node-gitlab-ci resolves automatically the extends keyword for you so you can fully profit from nested jobs without limitations (e. g. nested extends with same keys like only are no covered by GitLab CI). This is done a deep merge mechanism:

config.job(
    "only production",
    {
        only: {
            refs: ["master"],
        },
    },
    true
);

config.extends(".only production", "my-job", {
    script: ["echo This job runs only in production!"],
});

You can also extend from multiple jobs:

config.job(
    "common files changed",
    {
        only: {
            changes: ["common/**/*"],
        },
    },
    true
);

config.extends([".only production", ".common files changed"], "my-job", {
    script: ["echo This job runs only in production and when common files got changed!"],
});

How macro works

With macros you can define callbacks and consume them with a set of parameters so you can dynamically create jobs with "hard coded" variables. The most excited use case is only in a monorepo:

type EsLintMacroArgs = MacroArgs & {
    prefix: string;
};

config.macro<EsLintMacroArgs>("lint eslint", (self, { prefix }) => {
    config.extends([`.common files changed`, `.lint eslint`], `${prefix} lint eslint`, {
        only: {
            changes: [`packages/${packageName}/{lib,scripts,test}/**/*.{js,jsx,tsx,ts}`],
        },
    });
});

And in your package you can use this macro as follow:

config.from<EsLintMacroArgs>("lint eslint", { prefix: "utils" });

Interact with the GitLab REST API

This package comes with @gitbeaker/node bundled, so you can directly communicate with the GitLab REST API. The API handler is brought to you with the following functionality:

// List last 500 jobs in your project
config.api.Jobs.all(1 /* your project id */, {
    maxPages: 5,
    perPage: 100,
});

Get changed files

If you need to detect changed file while child pipeline generation, you can use the following:

const changed = config.hasChanged(); // returns string[]
const specificFileHasChanged = config.hasChanged(/^packages\/my-package\//gm);

Use installed modules

As mentioned previously you can not import or require any module. If you want to do so, you need to consider the following:

  • Open a Pull Request or Issue here and ask to install the module globally in the image
  • Create your own Dockerfile with the modules installed globally (e. g. npm install --global fs-extra), extended from this dockerfile
  • Modify the ts config job and install the modules globally or locally

Todo:

This repository is still in beta phase and the following things should be done:

  • Use debug package instead of console.log
  • Create GitLab CI with semantic-release to automatically publish the package to npmjs.org
  • Create and push docker image through CI instead of hub.docker.com
  • Write Tests

License

MIT

Keywords

FAQs

Package last updated on 14 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc