0.0.14 • Published 6 years ago

dummy-app v0.0.14

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

node-cd-pipeline

Continuous Delivery Pipeline for Node.js Application

Requirements

  • Node.js version v8.11.3
  • NPM version 5.6.0
  • Mocha version 3.5.0

Useful Links

Install, Test and Run The Application

  • Install the application:
npm install
  • Test the application:
npm Test
  • Run the application:
npm start

Generate Docker Image for Running Jenkins with Node.js

The docker image is described in docker/Dockerfile and based on Jenkins Community Docker image. The image will run Jenkins, with Node.js and NPM installed. It will also have the jenkins plugins specified in jenkins-plugins.txt file installed and the jenkins jobs restored from there configuration. This should require minimum configuration effort of Jenkins to get the CD pipeline up and running.

  • Build the image (without cache) from folder docker/:
docker build --no-cache -t jenkins-nodejs .
  • Run the image (detached mode and automatic restart):
docker run -d --restart always -p 8080:8080 -p 50000:50000 jenkins-nodejs

Configure Jenkins for running the Pipeline

  • Install plugins required by the pipeline:

    • Pipeline Plugin
    • Git Plugin
    • GitHub
    • SSH Agent
    • Config File Provider
    • Pipeline NPM Integration
  • Configure credentials for connecting to git repository (e.g. ssh) with ID GIT_CREDENTIALS.

  • Configure global environment variables GIT_USERNAME and GIT_EMAIL that will be used for setting up the Git repository.
  • Configure Custom Configuration file NPM_CONFIG that contains the credentials for authenticating to NPM registry.

Tips for Jenkins

Jenkins.instance.pluginManager.plugins.each{
  plugin ->
    println ("${plugin.getShortName()}:${plugin.getVersion()}")
}

Store the list of plugins to docker/jenkins-plugins.txt so that these plugins get installed when creating the docker image.

Tips for Authenticating to NPM registry

Publishing a new version of a Node.js application to a NPM registry requires authenticating the user with a token using the addUser command which will update the .npmrc file with the registry and authentication token.

# Connect to the docker container
docker exec -it {containerId} /bin/bash

# Add the NPM user
npm addUser --always-auth=true --registry={registry URL (.e.g https://registry.npmjs.org/)}

# Content of the .npmrc file
cat .npmrc
0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.7

6 years ago