Installing and Deploying Jenkins on an ECS
Preparations
- Before installing Jenkins, purchase an ECS (recommended configuration: 4 GB+ memory and 40 GB+ disk size) running CentOS 7.6. Bind an EIP to the ECS.
- After the ECS is purchased, add the inbound rule listed in the following table to the security group which the ECS belongs to. For details, see Adding a Security Group Rule.
Direction
Priority
Action
Type
Protocol & Port
Source Address
Inbound
1
Allow
IPv4
TCP: 8080
0.0.0.0/0
Procedure
- Install JDK.
To ensure compatibility with Jenkins, install OpenJDK 11 (view supported Java versions).
- Remotely log in to the purchased ECS.
- Run the following command to view the current JDK version:
If JDK exists and its version is earlier than 11, uninstall the JDK.
rpm -qa | grep java | xargs rpm -e --nodeps
- Install JDK 11.
- Restart the ECS.
- Check whether the installation is successful.
- Install Jenkins.
- Run the following commands one at a time:
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install -y jenkins --nogpgcheck
- Edit the Jenkins file.
vim /etc/sysconfig/Jenkins
#Port JENKINS_PORT="8080" #Modify the user $JENKINS_USER="root" #Modify directory permissions chown -R root:root /var/lib/jenkins chown -R root:root /var/cache/jenkins chown -R root:root /var/log/Jenkins
- Start Jenkins and check its status.
systemctl status jenkins
- Run the following commands one at a time:
- Unlock Jenkins.
- In the address bar of your local browser, enter http:EIP bound to the ECS hosting Jenkins:8080. The unlocking page is displayed.
- Log in to the ECS.
- Obtain the activation password.
cat /var/lib/jenkins/secrets/initialAdminPassword
- On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.
- Install suggested plugins. After the installation is complete, use the admin account to go to the next step.
- Save the settings and complete the installation. The Jenkins page is displayed.
- In the address bar of your local browser, enter http:EIP bound to the ECS hosting Jenkins:8080. The unlocking page is displayed.
Verification
Single Job
- Choose New item, select Freestyle Project, click OK.
- In Build Steps, select Execute shell, enter echo hello world; exit, and click OK.
- Click Build Now.
- Wait until the execution of build task in the lower left corner is complete. Click Console Output, you can see the job is finished and hello world is displayed.
Multiple Jobs
- On the plug-in management page, search for the MultiJob plug-in and install it.
- Click New item, select MultiJob Project, and click OK.
Before creating a MultiJob project, you need to create three jobs.
- In Build Steps, select MultiJob Phase.
- Add three jobs as follows:
- Save the settings. The jobs are added.
- Click Build Now. The three jobs are successfully built in sequence.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot