Home > Web Front-end > Front-end Q&A > jenkins container installation nodejs

jenkins container installation nodejs

WBOY
Release: 2023-05-23 22:22:06
Original
3153 people have browsed it

In modern software development, integration testing is a crucial link. Jenkins is a very popular tool for automating builds and testing. At the same time, the Node.js platform is also very commonly used in JavaScript development. So how to install Node.js in the Jenkins container? This article will walk you through the process.

Before installing Node.js, you need to install the Jenkins container first. You can run Jenkins containers locally through DockerHub or the Docker command line. Jenkins officially provides a method to install Jenkins using the Docker command line. Please refer to the following command:

docker run --name myjenkins -p 8080:8080 -p 50000:50000 jenkins/jenkins
Copy after login

After running, you can open the Jenkins UI through the browser. By default, Node.js is not installed in Jenkins, so you need to install it manually. Next, we will introduce two methods of installing Node.js in the Jenkins container.

Method 1: Use the Node Manager plug-in (NodeJS Plugin)

The Node Manager plug-in is an official plug-in provided by Jenkins, which can simplify the installation and configuration process of Node.js. The following are the steps to install Node.js:

1. Log in to Jenkins and enter the plug-in management page: http://localhost:8080/pluginManager/

2. Search for "NodeJS" in the search box Plugin" and select Install.

3. After the installation is completed, find the "Global Tool Configuration" option on the "System Management" page and enter the configuration interface.

4. In the "NodeJS" section, click "Add NodeJS" and the node will appear in "NodeJS Installations".

5. In "NodeJS Installations", you can set the installation path and version number of Node.js.

6. After the configuration is completed, in your Jenkinsfile or Freestyle Project, you can select the Node.js version you just configured in "Build Environment" to ensure that the project can use that version of Node.js .

Method 2: Manually install Node.js

If you are already familiar with the installation process of Node.js, you can choose to skip the installation of NodeJS Plugin and install Node.js manually. The following are the steps to manually install Node.js:

1. Log in to the Jenkins container and execute the following command:

$ sudo apt-get update
$ sudo apt-get install curl
Copy after login

2. Download the Node.js binary file and unzip it:

$ curl -s https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz | tar -xJf -
Copy after login

3. Move the decompressed folder of the Node.js binary file to /usr/local/:

$ sudo mv node-v10.16.3-linux-x64 /usr/local/
Copy after login

4. Add the path of the Node.js binary file to the PATH environment variable:

$ export PATH=$PATH:/usr/local/node-v10.16.3-linux-x64/bin/
Copy after login

5. In your Jenkinsfile or Freestyle Project, you can use Node.js through shell commands or other means.

Summary

Installing Node.js in the Jenkins container can help us better integrate testing. Using the Node Manager plug-in can help us simplify the installation and configuration process of Node.js, while manual installation of Node.js requires some basic knowledge of the Linux environment. Which method to choose depends on your actual situation. However, no matter which way you choose, you will have a more free and flexible testing environment.

The above is the detailed content of jenkins container installation nodejs. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template