Web3 Meets DevOps: Creating the Initial Structure of Pipeline | by Donovan Brown | Jun, 2022

Web3 needs DevOps

Part-4 — Building a DevOps pipeline for the Ethereum blockchain

Photo by Fotis Fotopoulos on Unsplash

In the previous post of this series Web3 Meets DevOps: Writing Address Service, I had the front end, contracts, and supporting code in place. In this post, I will start the creation of our pipeline.

Before I could start building my pipeline I needed to publish my changes to a remote git service. Although I am using Azure Pipelines for my DevOps pipeline I used GitHub to store my source. Azure Pipelines and GitHub work great together and I get the best of both worlds.

If you need help creating an Azure DevOps project (to hold your Azure Pipeline) or creating and pushing your code to a GitHub repository you can use the links below:

I created a new branch named “blog/part4” for this post.

git checkout -b blog/part4
1* M TnY NNi IBuRp0DEs9Q
Pipelines menu and Create Pipeline button

With my code pushed to GitHub I navigated to the Pipelines page of Azure DevOps and clicked the Create Pipeline button.

Then I selected GitHub when asked “Where is your code”. I selected the repo with my code and then selected Starter pipeline.

Azure Pipelines can be made up with Stages, Jobs, and Steps. To get started I decided to lay out my stages and jobs. This allowed me to define dependencies between stages and jobs and see my entire pipeline.

Using the web editor I updated the code to define my pipeline structure. My pipeline has six stages:

  1. build: compiles, tests, and packages artifacts
  2. dev: deploys infrastructure, contracts and frontend
  3. dev_validation: waits for manual validation of dev and deletes dev environment
  4. qa: deploys infrastructure, contracts and frontend
  5. qa_validation waits for manual validation of qa and deletes qa environment
  6. prod: deploys infrastructure, contracts and frontend
Initial pipeline structure

I saved and ran my pipeline to confirm everything was structured correctly and running.

Six stage Azure Pipeline with all green check marks
Successful run of the pipeline

After the initial run of the pipeline I synced my changes to my local development machine to pull the azure-pipelines.yml file down. This is the file that contains the definition of my pipeline.

To make my pipeline easier to create I added a package.json file in the root of my project that contained the Truffle dependency. Azure Pipelines use Microsoft-hosted agents to run. They contain the most common packages, and I can add additional packages via a package.json file.

In this case, I need to add Truffle. The pre-installed packages are listed here. Truffle must be installed to compile, test, and migrate the contracts. Installing Truffle in the root will create a node_modules folder that does not need to be tracked. So, I added it to the .gitignore file in the root of the project.

Added node_modules to .gitignore

Then I ran the following command:

npm install --save-dev truffle

I decided to create a package.json file just in case I needed additional packages in the future.


Finally, I committed all the changes.

git add package.json
git add package-lock.json
git commit -a -m "adding pipeline yaml"

Then I merged my changes into main.

git checkout main
git merge blog/part4

In the next post of this series, I will complete the build stage of the pipeline.

Editor: Chelsea Brown
Technical Review: Brian Benz

News Credit

%d bloggers like this: