Git Product home page Git Product logo

jenkins-yaml's Introduction

Wolox CI

This a Jenkins library built to make it easier for us at Wolox to configure pipelines without necessarily knowing about Jenkinsfile syntax. All our projects are built using a Dockerfile

When using this library, your Jenkinsfile should look something like this:

@Library('jenkins-yaml') _

node {

  checkout scm

  jenkinsYAML('docker/config.yml');
}

It basically loads the library, clones the target repository and calls jenkinsYAML to make its magic. As an argument, jenkinsYAML receives the path to a configuration yaml file. This file looks something like this:

config:
  dockerImage: library/redis
  project_name: some-rails-project

services:
  - mssql

steps:
  analysis:
    - bundle exec rubocop -R app spec --format simple
    - bundle exec rubycritic --path ./analysis --minimum-score 80 --no-browser
  setup_db:
    - bundle exec rails db:create
    - bundle exec rails db:schema:load
  test:
    - bundle exec rspec
  security:
    - bundle exec brakeman --exit-on-error
  audit:
    - bundle audit check --update


environment:
  RAILS_ENV: test
  GIT_COMMITTER_NAME: a
  GIT_COMMITTER_EMAIL: b
  LANG: C.UTF-8

This file has different sections:

Configuration

The section under the config label defines some basic configuration for this project:

  1. The dockerfile that contains the image for the project to run.
  2. The project name.

Services

This section lists the project's dependencies. Each section will define and expose some environment variables that might be needed by the application:

Microsoft SQL

When listing mssql as a service, this will build a docker image from microsoft/mssql-server-linux exposing the following environment variables:

  1. DB_USERNAME
  2. DB_PASSWORD
  3. DB_HOST
  4. DB_PORT

Postgres

When listing postgres as a service, this will build a docker image from postgres exposing the following environment variables:

  1. DB_USERNAME
  2. DB_PASSWORD
  3. DB_HOST
  4. DB_PORT

Redis

When listing redis as a service, this will build a docker image from redis exposing the following environment variables:

  1. REDIS_URL: the redis url that looks like this redis://redis

Steps

This section lets you define the steps you need to build your project. Each level inside the steps section is a stage in the Jenkins pipeline and each item in the stage is a command to run. In the case above, there are 5 stages named:

  1. analysis
  2. setup_db
  3. test
  4. security
  5. audit

The analysis stage, for example, runs the following commands:

  1. bundle exec rubocop -R app spec --format simple
  2. bundle exec rubycritic --path ./analysis --minimum-score 80 --no-browser

Environment

This section lets you set up custom environment variables. Each item inside this section defines a variable with its value.

jenkins-yaml's People

Contributors

martum avatar sbalay avatar

Watchers

James Cloos avatar Adam avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.