Web3 needs DevOps
Part-4 — Building a DevOps pipeline for the Ethereum blockchain
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
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:
build: compiles, tests, and packages artifacts
dev: deploys infrastructure, contracts and frontend
dev_validation: waits for manual validation of dev and deletes dev environment
qa: deploys infrastructure, contracts and frontend
qa_validationwaits for manual validation of
prod: deploys infrastructure, contracts and frontend
I saved and ran my pipeline to confirm everything was structured correctly and running.
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
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.
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
git checkout main
git merge blog/part4
In the next post of this series, I will complete the build stage of the pipeline.
CreditsEditor: Chelsea Brown
Technical Review: Brian Benz