We’ll look into how Jenkins and Node can help you get starting quickly. To enable continuous deployment depending on modifications to a GitHub repository, JavaScript can be made to cooperate.

So let’s choose the strategy here. We’re going to use a React JS repository that already exists from our well-liked “React From Scratch” workshop. Jenkins might create, deploy, and/or run the application in response to changes made to this repository. Due to Node.js’s nature, the build process will guarantee that the NPM modules are present.

We must have the most recent Node.js version installed because this pipeline uses Jenkins and Node.js. We also need Java installed since Jenkins is a Java application. Since my example application does not employ Nettyfy Technologies, anyone can utilise this instruction with ease.

Setting up Jenkins with the Required Plugins

Jenkins ought should have been downloaded by now. Get the WAR file from the Jenkins website now if you haven’t already.

Use your Command Prompt or Terminal to run the following command to launch Jenkins:

java -jar jenkins.war -httpPort=8080

By doing this, Jenkins will be reachable via a web browser at http://localhost:8080. You’ll enter a configuration wizard on the first launch.

The password that Jenkins creates will be requested on the first screen of this setting procedure. Locate it where it is indicated on the screen.

You can choose which plugins to install on the second screen.

We’re going to install the suggested plugins for the time being. Later on, we’ll instal other plugins.

We must create our first administrative user on the third screen. Although you are technically an administrator user with the generated password you are using, you might want to make a new one.

Jenkins is ready to use once you’ve created a user. However, another plugin will be required, and the one we use will depend on how we want to develop and deploy the Node.js application.

To view a list of administration options, select Manage Jenkins from the main Jenkins interface.

Managing the available plugins is what we are interested in. After selecting Manage Plugins, we want to look for and instal the PostBuildScript plugin.

After the build step is finished, we can run shell commands or scripts thanks to this plugin. We’ll build and deploy to the same host in this example, and we may execute all shell operations locally. You might want to utilise the SSH plugin to transfer the code to a remote server in a production setting so that it can be executed there.

Let’s build our Jenkins continuous deployment pipeline for Node.js using the available plugins.

Creating a Node.js Continuous Deployment Workflow in Jenkins

Just to be clear, our objective is to develop a workflow that will download a project from GitHub, instal all of its dependencies, and run it on a server—in this example, our local computer—to deploy it.

Create a new item, often referred to as a new task or workflow, to get things started.

A Freestyle Project will be developed. On the following screen, there are three tasks that must be completed.

Our workspace will have GitHub as its source. It can come from somewhere else in your own project, but we need to declare our source control information for this one. If your project doesn’t use the master branch, you can still choose the branch.

I already built and wrote about the GitHub project, as was already described. The project is available at:

https://github.com/couchbaselabs/space-x-app

Now that the job process is on localhost, GitHub won’t permit you to set up GitHub hooks to initiate it in a production environment. We’ll manually start the job in its place.


We must configure the build step after configuring the source control section. Building for Node.js merely entails installing dependencies, however unit testing or other tests might easily be included at this phase. The build step includes more in the Jenkins Java project. The only thing present in this Node.js example is what follows:

We can now specify what occurs after the project is completed.

In this instance, the application will be installed locally on our computer. In your production setting, this probably isn’t the case.

As a result, you’ll see that we have the following commands in our post-build step:

By selecting Build Now from the list of alternatives, try running the job. The project should be downloaded, installed, and made accessible at http://localhost:3000. Simply ensure that Couchbase Server is running for this project; otherwise, issues will occur.

Conclusion

You just learned how to use Jenkins to automatically deploy Node.js programs depending on changes posted to GitHub. If you’re a Java developer, you should take a look at Create a Continuous Deployment Pipeline with Jenkins and Java, which is a comparable approach made specifically for Java applications.

Are you interested in learning more about using Node.js with Nettyfy Technologies NoSQL? For additional information, visit Nettyfy Technologies’ website to hire Node.js developers.