Three ways to build Jenkins in Linux environment __linux

Source: Internet
Author: User

There are three ways of installing Jenkins:

Mode one:

Download war package, download address: Http://ftp.yz.yamagata-u.ac.jp/pub/misc/jenkins/war/2.31/jenkins.war

Put the war directly under Tomcat's WebApps.

[Root@s120101 webapps]# Ls-la
Total dosage 114204
Drwxr-x---9 root 4096 November 16 15:36.
Drwxr-xr-x 9 root 4096 November 16 09:43.
Drwxr-x---root 4096 November 09:43 docs
Drwxr-x---6 root 4096 November 09:43 examples
Drwxr-x---7 root 4096 November 09:48 Gitbucket
-rw-r--r--1 root root 47147063 November 17:37 Gitbucket.war
Drwxr-x---5 root 4096 November 09:43 Host-manager
Drwxr-x---Root 4096 November 15:36 Jenkins
-rw-r--r--1 root root 69757994 November 14:04 Jenkins.war
Drwxr-x---5 root 4096 November 09:43 Manager
Drwxr-x---3 root root 4096 November 09:43 root
[Root@s120101 webapps]# pwd
/root/apache-tomcat-8.5.8/webapps

Restart Tomcat

Login http://Host IP: Port/jenkins

reproduced below:http://blog.csdn.net/yanmingming1989/article/details/8557716/

Mode two:

Linux main clause execution:

sudo java-jar jenkins.war–httpport=18080–ajp13port=18009

But most of the time we use SSH to the target machine, let us close the SSH connection, this command will be interrupted, the Jenkins service will be terminated, we can not keep this SSH connection, how to do. You can write this line of command as a shell script and then use Nohup sh jenkins.sh &
command to start the script so that Jenkins can provide the service normally.
Installation mode two: Install the RPM package
To be able to use the Jenkins Library, you first need to import the key for the Jenkins Library:
[Java] View plain copy sudo wget-o/etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm –import Http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key installation software (take jenkins-x.x.x.rpm as an example): Yum Install jenkins-x.x.x.rpm
Delete software: Yum remove jenkins-x.x.x.rpm or yum erase jenkins-x.x.x.rpm
Upgrade software: Yum upgrade Jenkins or yum update Jenkins
Query information: Yum Info Jenkins
Turn on service (shutdown, reboot): [Java] view plain copy sudo service Jenkins start|stop|restart Check Jenkins installation complete: localhost:8080 (default is 8080 Port, if the installation mode one, then need to specify the port)
Problems encountered while running the job:
Mvn:command not found
Problems encountered: Cannot use the MVN command;
Troubleshooting Procedures:
①jenkins The default creation process, the user name to start the task is Jenkins, the user can see the passwd by default, which means that users will not be able to use SSH to log on by default, unless you modify passwd the corresponding field in bash and then sourse;
Jenkins:x:500:500:mengqc:/home/jenkins:/bin/fasle
passwd file Format: Registration name: Password: User id: Group ID: User name: With head of Household directory: command interpreter
② By default Jenkins's installation directory is/var/lib/jenkins/, and the project root directory is/var/lib/jenkins/jobs/workspace

From the directory, we know that this is the need for root permissions to execute some commands, but we use the interface to execute some commands using the Admin user, even if we can adapt to the root directory mvn command, but the problem can not be solved.

There is also a simple test of whether Maven is added to the environment variable, and when executing the MVN command, fill in the absolute path of the MAVEN installation, which, if executed, is not a matter of permissions, but of an environment variable.

Solution One: ① install ssh slave plugin;
② start slave service;
③jenkins-System Management-node management: RESET Slave machine's Remote FS root to/home/admin/xxx
(mainly added to the workspace directory) $ITEM _rootdir
④ sets the number of nodes in master to 0 so that the slave node is used by default.
Problem:
If you modify the working directory (Remote FS root), you may experience:
[Java] View plain copy "main" Java.lang.noclassdeffounderror:hudson/maven/agent/main Reason: We modified slave's working directory, However, the slave service did not restart the cause;
Workaround: Use our script to restart the slave operation.
Solution Two:
Create a new working directory in the/home/admin/directory, and then set the/var/lib/jenkins directory to a jump link, linked to the admin directory [sudo ln-s/home/admin/xxx//var/lib/jenkins], Then the/var/lib/jenkins directory under the file MV to the/home/admin/xxx/directory.
MVN and some basic commands can be run, but still do not have permission to run the shell script, because the new jump connection User=root, Group=root, and the use of this link chown/chgrp is not effective, Perform some operation command or no permissions;
Solution Three: Modify the default Jenkins user admin
① Installation Jenkins
Java code (we typically use admin permissions)
[Java] View plain copy sudo wget-o/etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo RPM--import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install Jenkins rpm-ql Jenkins

②. Configure Jenkins
Java code
Edit Jenkins_port, Jenkins_user
sudo vi/etc/sysconfig/jenkins (set Jenkins_user to admin)
③. Modify Jenkins permissions (if modified Jenkins_user)
Java code
[java]  View Plain  copy ####   sudo chown -r admin /usr/lib/jenkins      sudo chgrp -r admin /usr/lib/jenkins    ####  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.