<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tung Nguyen</title>
    <description>The latest articles on DEV Community by Tung Nguyen (@tungnt620).</description>
    <link>https://dev.to/tungnt620</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F72213%2Fcec5c3d6-d0f7-4bea-bc3e-42b517485fb4.jpeg</url>
      <title>DEV Community: Tung Nguyen</title>
      <link>https://dev.to/tungnt620</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tungnt620"/>
    <language>en</language>
    <item>
      <title>Deploy Jenkins job from the command line and chrome notification for job result</title>
      <dc:creator>Tung Nguyen</dc:creator>
      <pubDate>Sat, 18 Apr 2020 14:14:59 +0000</pubDate>
      <link>https://dev.to/tungnt620/deploy-jenkins-job-from-the-command-line-and-chrome-notification-for-job-result-24el</link>
      <guid>https://dev.to/tungnt620/deploy-jenkins-job-from-the-command-line-and-chrome-notification-for-job-result-24el</guid>
      <description>&lt;h2&gt;
  
  
  Reason:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Current my daily tasks are:

&lt;ol&gt;
&lt;li&gt;Develop feature&lt;/li&gt;
&lt;li&gt;Create a git merge request&lt;/li&gt;
&lt;li&gt;Create a git tag&lt;/li&gt;
&lt;li&gt;Go to Jenkins site and deploy to a specify env and git tag above&lt;/li&gt;
&lt;li&gt;Wait for Jenkins build result&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;So, I think I can make the process at step 4 and 5 more automatic&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A script for deploy Jenkins from the command line

&lt;ul&gt;
&lt;li&gt;So we no need switch to Jenkins page, now you can do everything on you IDE&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;A chrome extension for notifying when build success

&lt;ul&gt;
&lt;li&gt;Another solution is set up a webhook for Jenkins so it can send the result to Slack or Mattermost group. But I think it still makes spam for me, I just want to notify on some projects.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Preconditions:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You must have Jenkins username and API token

&lt;ul&gt;
&lt;li&gt;API token get at Configure tab on the account info page&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Script for deploy Jenkins from the command line
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It uses Jenkins API for send deploy request&lt;/li&gt;
&lt;li&gt;Basically, all of it is do this command
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -v -X POST https://jenkins.com/job/admin-apibuild \
  --user yourusername:yourapitoken \
  --data-urlencode json='{"parameter": [{"name":"Environment", "value":"test"}, {"name":"COMMIT", "value":"dev"}]}'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Value of &lt;code&gt;parameter&lt;/code&gt; depend on the config of your Jenkins job&lt;/li&gt;
&lt;li&gt;I wrapper above curl command to Javascript file, so you need Node to run&lt;/li&gt;
&lt;li&gt;We can run a command like &lt;code&gt;node scripts/deploy.js dev v1.1.1&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;You can custom to correct with your Jenkins config&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Source code at &lt;a href="https://github.com/tungnt620/jenkins-auto"&gt;&lt;/a&gt;&lt;a href="https://github.com/tungnt620/jenkins-auto"&gt;https://github.com/tungnt620/jenkins-auto&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A chrome extension for notifying when build success
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How it works
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;We have a monitor server which uses for interval fetch status of jobs

&lt;ul&gt;
&lt;li&gt;We choose jobs to want to monitor&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;This monitor server also serves an API get notifies which used by chrome ext&lt;/li&gt;
&lt;li&gt;Chrome ext interval fetch notifies from the monitor server and displays it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tUmvNPT4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/khms5zw4lmjbapf193xx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tUmvNPT4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/khms5zw4lmjbapf193xx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can see detail at &lt;a href="https://github.com/tungnt620/jenkins-auto"&gt;https://github.com/tungnt620/jenkins-auto&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The end
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I think one way to boot productivity is to avoid context switch as much as possible.&lt;/li&gt;
&lt;li&gt;If you have any other ways, solutions please share with us&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>javascript</category>
      <category>jenkins</category>
      <category>chromenotification</category>
    </item>
    <item>
      <title>Recap about Webpack</title>
      <dc:creator>Tung Nguyen</dc:creator>
      <pubDate>Fri, 29 Nov 2019 03:51:16 +0000</pubDate>
      <link>https://dev.to/tungnt620/recap-about-webpack-2dad</link>
      <guid>https://dev.to/tungnt620/recap-about-webpack-2dad</guid>
      <description>&lt;h3&gt;
  
  
  What is Webpack?
&lt;/h3&gt;

&lt;p&gt;Webpack is a module bundler, it helps pack our application from multiple files to one or a few files which can run on target environments ( ex: web browser).&lt;br&gt;
For example with a modern react application, we have many files: css, scss, fonts, image, js, jsx and in each file we also import/use other files. Webpack help we pack their files together in a bundle file and it can run in the web browser&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7yMG2K96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vcs0380nrhafr88ba4nu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7yMG2K96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vcs0380nrhafr88ba4nu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why we need Webpack?
&lt;/h3&gt;

&lt;p&gt;Assume we don't have Webpack or any module bundler and we have a react web application.&lt;br&gt;
To our web can run in a web browser correctly, at least we need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;index.html file&lt;/li&gt;
&lt;li&gt;in index.html file need a script tag with a link to React library source&lt;/li&gt;
&lt;li&gt;in index.html file need a script tag with a link to React DOM library source&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Depend on the requirement, usually, we need style ( add some stylesheet tags to link to css files), other script tags to other libraries. In a complex project, it very hard to manage&lt;br&gt;
Webpack can help us by let we easy define the relationship in our's app by use import statement, Webpack will auto pack code need for our's app run&lt;/p&gt;

&lt;h3&gt;
  
  
  How Webpack work?
&lt;/h3&gt;

&lt;p&gt;Internally, Webpack begins at an entry file ( usually index.js file ) and from this file, it builds a dependency graph of our's application. From this graph, Webpack can produce a bundle file have all resource, code, library necessary for app run.&lt;br&gt;
With every import, it is a command say Webpack that is a dependency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Components of Webpack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Entry:

&lt;ul&gt;
&lt;li&gt;Use to indicate where Webpack begin to build dependency graph&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Output

&lt;ul&gt;
&lt;li&gt;Use to indicate where and name of bundle files&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Loaders

&lt;ul&gt;
&lt;li&gt;By default, Webpack only understand and bundle JS and JSON file&lt;/li&gt;
&lt;li&gt;Loader help Webpack can understand other file types and build dependency graph&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Plugins

&lt;ul&gt;
&lt;li&gt;This component helps Webpack can do tasks like bundle optimization, asset management, injection of environment variables, minify, ...&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Webpack have many loaders and plugins help we build a modern application ( not only web it can use to bundle other application like Rail, ... )&lt;br&gt;
We also can write custom loaders and plugins to extend function of Webpack (like)&lt;/p&gt;

</description>
      <category>webpack</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Distinguish Babel and Webpack</title>
      <dc:creator>Tung Nguyen</dc:creator>
      <pubDate>Wed, 13 Nov 2019 06:55:34 +0000</pubDate>
      <link>https://dev.to/tungnt620/distinguish-babel-and-webpack-4mb2</link>
      <guid>https://dev.to/tungnt620/distinguish-babel-and-webpack-4mb2</guid>
      <description>&lt;p&gt;Sometimes I still confuse about Babel and Webpack, so I noted this for reference reason&lt;/p&gt;

&lt;h3&gt;
  
  
  Babel
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Not all new feature of JS support by all browsers, Babel compile source code to version which can work on any browser&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Webpack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is a bundler for JS and static files. It packs many files, modules into a few files&lt;/li&gt;
&lt;li&gt;It also has some function like code-splitting, lazyloads help make our's app more effective&lt;/li&gt;
&lt;li&gt;It also allows we can write custom packing logic with "loader" plugin&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;Usually, in the modern web application, Babel and Webpack used together&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
