Skip to main content

Jenkins Pipeline

The package provides a convenient means to generate only the Jenkinsfile by utilizing the Jenkinsfile file generator. This workspace generator is an exemplary tool that can be effortlessly updated and maintained by client developers. You can find it in the project's root directory under tools/generators/@genesis-jenkinsfile-template.

Usage

To create Jenkins Pipeline, you can follow the steps outlined below:

Pre-requisites

  • Make sure you are on correct version of Nodejs 18.x and Nx Version 16.6

    node --version
    nx --version
  • To start with, create a new GenesisX workspace in an empty directory, run below command, of if you already have the workspace ready , please skip this step.

    npx @genesisx/create-workspace
    • Provide the requested parameters

    • Provide name to your workspace like test-workspace

    • Move to the created workspace - cd test-workspace

    • Install the packages

      yarn install
  • Install Jenkins Pipeline package

    yarn add @genesisx/jenkins
  • Now follow either of the two modes(mentioned below) to use this generator - either the Nx Console or CLI

Via Nx Console

  1. Use Nx Console > Generate > @genesisx/jenkins

  2. Fill in the following inputs

PROJECT_NAME

The name of the project to be built

VERSION

The genesis version number

NAMESPACE

The namespace to be used

RELEASE_NAME

Release name

gitWorkFlow = ''
Optional value

registry
Your email

credentialsID *
Enter your credentials ID

userVar *
Enter username

passVar *
Enter your password


  1. It should produce a file called /Jenkinsfile in the root folder as below
PROJECT_NAME = 'genesis_docs'
VERSION = '1.1.1'
NAMESPACE = 'nmspace_gen'
RELEASE_NAME = 'generic_release'
gitWorkFlow = ''
registry= 'user@domain.com'

withCredentials

credentialsId:
passwordVariable:
usernameVariable:

The Jenkinsfile is a file that Jenkins reads to decide on what stages to activate

Via Command Line

nx generate @genesisx/jenkins:template

More about this package

The purpose of this file is to be able to force a Jenkins CI/CD on a specific app project by DevOps or Developers. It comprises of following stages:

  • Checkout
  • Prepare
  • Lint
  • UnitTest
  • Build
  • Dockerize
  • Deployment

Core parts to setup using groovy language

###Checkout
This stage setup git modules and checkout code merge is possible for feature & master branch

###Prepare
This stage setup the base modules needed by respective projects for subsequent stages.

###Lint && UnitTest
These Stages runs linting and unit test check against config made in the projects.eg files: jest.config.js, .eslintrc.json

###Build & Docker
These stages build the apps and create docker images for affected applications and publish those images to artefactory store. '''here PS docker registry been used'''

###Deployment
This stage leverage the k8 config in each apps to deploy app to infra configured in those files. i.e: ingress,service, deployment yaml.
info

Using the Nx framework, we can optimize pipelines and make it easier to run affected applications.

yarn nx affected:apps --all

More details & Troubleshooting

Visit the troubleshooting guide for common issues or refer to the readme.md file located within the package folder <workspace-folder>/node_modules/@genesisx/jenkins/README.md