-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.xml
101 lines (93 loc) · 6.81 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Scribbles by Rifhan</title>
<link>https://blog.rifhanakram.com/</link>
<description>Scribbles by Rifhan</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<lastBuildDate>Tue, 27 Oct 2020 00:29:58 +0530</lastBuildDate>
<atom:link href="https://blog.rifhanakram.com/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>CI/CD for Monorepo's With Jenkins</title>
<link>https://blog.rifhanakram.com/posts/jenkins-pipeline-monorepo/</link>
<pubDate>Tue, 27 Oct 2020 00:29:58 +0530</pubDate>
<guid>https://blog.rifhanakram.com/posts/jenkins-pipeline-monorepo/</guid>
<description><p>Monorepo is an approach in managing source code under a product, team or company within a single repo as oppose to multi-repo where a single product/application is contained within its own git repository.</p>
<p>The two approaches has its own pro&rsquo;s and con&rsquo;s. In this article i will not be discussing on what is the best approach as it entirely matters on the context we work, rather i will walk the through the challenges of Automated CI/CD with <strong>mono-repo</strong> and how we can over come them with structure and some magic with <a href="https://www.jenkins.io/doc/book/pipeline/">Jenkins Pipeline</a>.</p>
<h2 id="challenges">Challenges</h2>
<p>Due to the nature of multiple applications residing in a single repo it is not trivial to setup a CI/CD job that detects changes and executes only the <strong>impacted applications related CI/CD pipeline</strong>. Some of the steps that contain in a typical pipeline are,</p>
<ul>
<li>Building the code</li>
<li>Running automated tests</li>
<li>Creating and versioning a deployable artifact</li>
<li>Deploying that artifact</li>
</ul>
<p>Lets look at how we can tackle this problem with Jenkins.</p>
<h2 id="some-jenkins-magic">Some Jenkins Magic</h2>
<blockquote>
<p><em>sample structure in a mono-repo setup with jenkins pipeline</em></p>
</blockquote>
<pre><code>.
├── src
├── react-app
├── Jenkinsfile
├── node-app
├── Jenkinsfile
└── Jenkinsfile # main jenkinsfile
</code></pre>
<p>If we consider a structure like above, with jenkins we could setup the main Jenkinsfile in the root of the repository as a <a href="https://www.jenkins.io/doc/tutorials/build-a-multibranch-pipeline-project/">multi-branch jenkins job</a>. This job can be connected with your remote repository such that it triggers via a webhook when a PR is merged to your mainline branch. You can get creative with the triggers depending on the workflow your team follows.</p>
<blockquote>
<p><em>A stage inside the main Jenkinsfile is shown below</em></p>
</blockquote>
<pre><code>stage('Execute Jobs') {
failFast false
parallel {
stage('react-app ci') {
when {
changeset &quot;src/react-app/**&quot;
}
steps {
build job: &quot;react-app-job&quot;, parameters: [string(name: 'branch_name', value: env.BRANCH_NAME)]
}
}
stage('node-app ci') {
when {
changeset &quot;src/node-app/**&quot;
}
steps {
build job: &quot;node-app-job&quot;, parameters: [string(name: 'branch_name', value: env.BRANCH_NAME)]
}
}
}
}
</code></pre><p>In the above example the <strong>changeset</strong> condition walks through the git changelog for that particular change and checks if there is any change within the given path. If a change is detected then the <strong>build job</strong> step executes the related jenkins job.</p>
<p>Note - <em><strong>failFast</strong> is set to false to avoid failure of the entire pipeline if one job fails.</em></p>
<p>Once we have this setup we can go about and setup separate pipeline jobs for each application in the repository.</p>
<blockquote>
<p><em>Below is an example on how the main multi-branch job will look in Jenkins</em></p>
</blockquote>
<p><img src="https://blog.rifhanakram.com/img/jenkins-multi-main.png" alt="jenkins-multi-main.png">
In the above image the multi-branch job has executed when a change has been pushed to the master branch. When we navigate into the master branch execution we can see the pipeline as shown below,</p>
<p><img src="https://blog.rifhanakram.com/img/jenkins-multi-stage-view.png" alt="jenkins-multi-stage-view.png"></p>
<p>In the stage view we can see that build #9 contains changes only for 1 application and build #10 contains changes for both.</p>
<p>This is an awesome and quick setup with Jenkins for a monorepo. I&rsquo;m a big fan of Jenkins due to its flexibility and extensibility specially with declarative <a href="https://www.jenkins.io/doc/book/pipeline/">Jenkins Pipeline</a>.</p>
</description>
</item>
<item>
<title>Tech Talks</title>
<link>https://blog.rifhanakram.com/posts/tech-talks/</link>
<pubDate>Tue, 27 Oct 2020 00:29:58 +0530</pubDate>
<guid>https://blog.rifhanakram.com/posts/tech-talks/</guid>
<description><h2 id="grpc-microservice-communication-with-aws-app-mesh">gRPC Microservice Communication With AWS App Mesh</h2>
<p>This talk was done at the 2020 July AWS User Group Colombo meetup. In this talk i walk through the challenges of microservice communication with gRPC and how we can use AWS App mesh to manage this communication and overcome the challenges mentioned.</p>
<h3 id="references">References</h3>
<ul>
<li><a href="https://www.youtube.com/watch?v=qXeBwMVCnSw">Video</a></li>
<li><a href="https://speakerdeck.com/rifhanakram/grpc-microservice-communication-with-aws-appmesh">Slides</a></li>
<li><a href="https://github.com/rifhanakram/gRPC-appmesh-demo">Code Samples</a></li>
</ul>
</description>
</item>
</channel>
</rss>