BlockChain Pipeline using Jenkins for DevOps

Overview

BlockChain Pipeline for Jenkins

This project is inspired by the work of Redback and Microsoft teams for developing the process using VSTS.

I've chosen to develop a similar DevOps process with Jenkins, Truffle and TestRPC so that we can give choices for our customers.

The project contains the components needed to create the test pipeline.

Building Jenkins Server

The current version is based on a single instance of Jenkins running Ubuntu 17.04. The scripts can be adapted for other Linux distributions as needed.

The script to automate the deployment is located at jenkins/master-install.sh. Jenkins installation is split into 2 routines. First, install the dev tools needed to compile and deploy Java and Node applications such as JDK, Node, npm, Git and Jenkins itself.

Followed by tools needed for running Ethereum locally on the Jenkins server. We'll be using Truffle Framework for writing contracts, integration tests and running tests. testrpc will provide an in-memory blockchain environment that's fast and predictable.

I've chosen to write the tests in Mocha as it's a versatile framework that can be used not just for Smart Contracts, but for integration testing across the entire application stack, thus allowing the developers to learn less and do more. The results are written into XML using the Mocha JUnit Reporter. The XML results can then be pulled into Jenkins as part of the build process.

Install Dev Tools

apt-get install -y openjdk-8-jdk-headless
apt-get install -y git

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
apt-get update
apt-get install -y jenkins

apt-get install -y python-software-properties
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -

apt-get install -y nodejs
apt-get install -y npm

Install Ethereum Tools

npm install -g ethereumjs-testrpc
npm install -g solc
npm install -g truffle
npm install -g mocha
npm install -g mocha-junit-reporter

mkdir -p /opt/ethereum/web3j
wget https://github.com/web3j/web3j/releases/download/v2.3.1/web3j-2.3.1.tar -O /tmp/web3j.tar
tar -xf /tmp/web3j.tar --directory /opt/ethereum/web3j --strip-components=1

Install Jenkins and Tools using Azure Resource Manager (ARM) Template

The full VM deployment and configuration can be automated through an ARM template. The template is located in jenkins/arm/deploy-ubuntu-master.json. This template will:

  • Setup a new virtual network, subnet, network security groups
  • Deploy an Azure Marketplace Ubuntu 17.04 VM with public IP address
  • Install Jenkins, Dev Tools and Ethereum Tools - this script is located in jenkins/install-jenkins-master-ubuntu.sh

You can customize the ARM template such that it can be:

  • Deployed into an existing environment
  • Restrict access through network security groups
  • Replace username/password for the VM with SSH Keys

To deploy using Azure Portal

  • Login to Azure Portal
  • From the left ribbon, search for Templates
  • Create a new template
  • Copy & Paste the contents of the JSON file
  • Save
  • Click Deploy, follow the prompts to completion

To deploy through Azure CLI

Download & install Azure CLI

# Start CLI in interactive mode & login
az interactive --style none
az login

# Create a Resource Group
az group create -l eastus -n blockchain-jenkins

# Deploy ARM template & enter the VM Username & Password
az group deployment create --resource-group blockchain-jenkins --template-uri https://raw.githubusercontent.com/zhihexireng/blockchain-jenkins/master/jenkins/arm/deploy-ubuntu-master.json

Wait about 10 minutes for the deployment process to complete.

# Retrieve the Public IP address of the Jenkins Server
az network public-ip show --resource-group blockchain-jenkins --name pip-jenkins-master

Access Jenkins via http://[public ip]:8080/

To deploy through PowerShell

Coming soon

Using Truffle Framework

An example Smart Contract and it's corresponding integration tests are located in the (/ethereum)[/ethereum].

To initialize a new project

cd <project directory>
truffle init

You should now have a few directories & files:

  • contracts/ - stores all Smart Contracts
  • tests/ - stores all test cases
  • migration/ - contracts that allow for deploying Smart Contracts to Blockchain
  • truffle.js - truffle configuration file

The Smart Contracts are written in Solidity and will store the files with .sol extension. There are example test cases written in Solidity (.sol extension) and Mocha (.js extension). The choice of the language is up to you.

Executing Integration Tests

You can run the integration tests against your own new project or the example Smart Contract(s) located in this project.

cd <project directory>

# Start testrpc in the background and save the pid.  You can set this up on another terminal as well.
testrpc &
echo $! >> testrpc.pid

# Run the tests
truffle test

# Stop testrpc
kill -9 `cat testrpc.pid`

Exporting Integration Test Results

You can export the integration tests into multiple formats. For this project, I'm using JUnit Reporter so that it can be read by Jenkins. The configuration is located in truffle-jenkins.js. To use this version, rename truffle-jenkins.js to truffle.js.

You might also like...

This is an example of how conditional events can be triggered in Camunda using a simple spring boot project

This is an example of how conditional events can be triggered in Camunda using a simple spring boot project

Camunda Conditional Events Example This example is a Spring Boot Application using Camunda. In this example i'll show a variety of ways that BPMN's Co

Sep 30, 2021

End to End project for Kafka Streams using Spring Cloud Kafka streams

End to End project for Kafka Streams using Spring Cloud Kafka streams

Spring Kafka Streams using Spring Cloud Streams End to End example Endpoint http://localhost:8080/domain/lookup/facebook - to pull all facebook relate

Dec 20, 2022

backend for a sharing app using SpringBoot, Redis, MySQL, and AWS S3.

backend for a sharing app using SpringBoot, Redis, MySQL, and AWS S3.

moments_v2_backend (Work In Progress) backend for a sharing app using SpringBoot, Redis, MySQL, and AWS S3. This is the second version of my project S

Dec 26, 2022

Spring Boot Refresh Token using JWT example - Expire and Renew JWT Token

Spring Boot Refresh Token using JWT example - Expire and Renew JWT Token

Spring Boot Refresh Token with JWT example Build JWT Refresh Token in the Java Spring Boot Application. You can know how to expire the JWT, then renew

Dec 28, 2022

Multi-Tenant Spring Boot Application with separate databases using Hibernate and H2.

Multi-Tenant Spring Boot Application A Spring Boot application that utilises a multi-tenancy architecture by providing multiple databases, one for eac

May 9, 2022

Simple AnimationUtil using Easing functions. Can be used anywhere, Hacked-Client, Mods, etc..

AnimationUtil Simple AnimationUtil using Easing functions. Can be used anywhere, Hacked-Client, Mods, etc.. Render example https://gyazo.com/780b5d8

Jan 8, 2023

Spring-boot application using redis as a caching database

Java Spring-boot application using Redis as a caching database Running Application Entities involved Two main entities are involved MasterHouse (maste

Aug 9, 2022

Human Resources Management System Using React with Java

Human Resources Management System Using React with Java

File Directory Main Adapters Abstract Concretes Business Abstract Concretes Core / Utilities Regex Results Upload Data Access Abstract Entities Concre

Jul 28, 2021

The Quotation Management application is a API REST created using Spring Boot framework.

The Quotation Management application is a API REST  created using Spring Boot framework.

✅ Quotation Management API - Done ✅ About • Features • Setup • Technologies • Author • License 💻 About The Quotation Management application is a API

Apr 29, 2022
Owner
Brantley·Williams
Work for Cryptagende
Brantley·Williams
A Jenkins plugin for inserting the commits changelog into the jenkins build environment.

commits-changelog-env-plugin A Jenkins plugin for inserting the commits changelog into the jenkins build environment. Jenkins插件, 在构建时通过将提交的更新列表插入 Jenk

Chen Pan 1 Feb 16, 2022
Ethereum blockchain-based e-portfolio management application built using Web3j API, java and solidity languages.

Web3j-Java-based e-Portfolio Manager Ethereum blockchain-based e-portfolio mangement application built using Web3j API, java and solidity languages. W

ibelab 6 Oct 1, 2022
PipelinR is a lightweight command processing pipeline ❍ ⇢ ❍ ⇢ ❍ for your Java awesome app.

PipelinR PipelinR is a lightweight command processing pipeline ❍ ⇢ ❍ ⇢ ❍ for your awesome Java app. PipelinR has been battle-proven on production, as

Eduards Sizovs 288 Jan 8, 2023
Jenkins automation server

About In a nutshell, Jenkins is the leading open-source automation server. Built with Java, it provides over 1,700 plugins to support automating virtu

Jenkins 20.1k Jan 9, 2023
jedibot is an application that aims to do beneficial actions on the Ethereum blockchain for the DeFi ecosystem while earning a profit for the user.

jedibot is an application that aims to do beneficial actions on the Ethereum blockchain for the DeFi ecosystem while earning a profit for the user. These actions include maintaining the DAI peg, providing liquidity and liquidating undercollateralized assets.

我是高天才! 10 Feb 5, 2022
MarioCash is a trust-based multi-dimensional blockchains built with a vision to connect everything and any blockchain networks.

MarioCash We will change the world by blockchain. What is mariocash? MARIOCASH is a trust-based multi-dimensional blockchains (branches) built with a

Brantley·Williams 23 Mar 10, 2022
A blockchain system to manage monetary transactions between the different nodes of a decentralized network.

Blockchain under a clear vision A blockchain system to manage monetary transactions between the different nodes of a decentralized network. Authors @s

SamDik 3 Jun 9, 2022
A java library for working with the Solana blockchain.

solanaj Updated version of p2p-org/solanaj Solana blockchain client, written in pure Java. Solanaj is an API for integrating with Solana blockchain us

paymennt 13 Dec 10, 2022
A web interface for viewing market data from Project Serum, on the Solana blockchain.

serum-data A web interface for viewing market data from Project Serum, on the Solana blockchain. Building Requirements (if not using Docker) Java 17 M

Michael Morrell 36 Jan 1, 2023
Search API with spelling correction using ngram-index algorithm: implementation using Java Spring-boot and MySQL ngram full text search index

Search API to handle Spelling-Corrections Based on N-gram index algorithm: using MySQL Ngram Full-Text Parser Sample Screen-Recording Screen.Recording

Hardik Singh Behl 5 Dec 4, 2021