Build Jenkins (Hudson) platform under Linux environment

Source: Internet
Author: User

To install Jenkins:
There are two ways of installing Jenkins:
Installation method One:

[Java]View PlainCopy
    1. sudo java-jar jenkins.war–httpport=18080–ajp13port=18009

But most of the time we use SSH to the target machine, when we close the SSH connection, this command will also 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 into a shell script and use nohup sh jenkins.sh &
command to start the script so that Jenkins can serve it normally.
Installation Method II: Install RPM Package
In order to be able to use the Jenkins Library, you first need to import the Jenkins Library key:

[Java]View PlainCopy
    1. sudo wget-o/etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm–import// Pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

Install the software (take jenkins-x.x.x.rpm as an example): Yum install jenkins-x.x.x.rpm
Remove 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 the service (shutdown, restart):

[Java]View PlainCopy
    1. sudo service Jenkins Start|stop|restart

Check if Jenkins is installed: localhost:8080 (default is port 8080, if one is installed, the specified port is required)
Issues encountered while running the job:
Mvn:command not found
Problems encountered: Cannot use the MVN command;
Troubleshooting process:
①jenkins default creation process, the user name of the startup task is Jenkins, with root permission to view passwd, you can see that this user by default, SSH is false, that is, this user by default is not able to use SSH login, unless modified The corresponding field in passwd is bash, and then sourse;
Jenkins:x:500:500:mengqc:/home/jenkins:/bin/fasle
passwd file Format: Registry name: Password: User id: Group ID: User name: Owner directory: Command interpreter
② By default, the installation directory for Jenkins is/var/lib/jenkins/, and the project root directory is/var/lib/jenkins/jobs/workspace

From the directory, we know that this requires root permission to execute some commands, but we do some commands through the interface using the Admin user, even though we can adapt to the MVN command in the root directory, but the problem can not be resolved.

There is also a simple test of whether MAVEN joins the environment variable method, when executing the MVN command, fill in the absolute path of the MAVEN installation, if able to execute, it is not the issue of permissions, but environment variables.

Solution One:
① installing SSH slave plugin;
② start slave service;
③jenkins-System Management-node management: Reset the slave machine's Remote FS root to/home/admin/xxx
(mostly added workspace directories) $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 encounter:

[Java]View PlainCopy
    1. "Main" Java.lang.noclassdeffounderror:hudson/maven/agent/main

Reason: We have modified the working directory of Slave, but the slave service has not been restarted;
Workaround: Use our script to restart the slave.
Solution Two:

Create a new working directory under the/home/admin/directory, and then set the/var/lib/jenkins directory to a jump link to the admin directory [sudo ln-s/home/admin/xxx//var/lib/jenkins], The files under the/var/lib/jenkins directory are then MV to the/home/admin/xxx/directory.
MVN and some basic commands can be run, but run the shell script still do not have permissions, because the new jump connection User=root, group=root, and the link to use CHOWN/CHGRP is not effective, Do some operations command yes or no permissions; solution Three: Modify the default Jenkins user to admin
① Installing Jenkins
Java code (we typically use admin permissions)
[Java]View PlainCopy
    1. sudo wget-o/etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
    2. sudo rpm--import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
    3. sudo yum install Jenkins
    4. Rpm-ql Jenkins


②. Configuring Jenkins
Java code
Edit Jenkins_port, Jenkins_user
sudo vi/etc/sysconfig/jenkins (set Jenkins_user to admin)
③. Modify the Jenkins permissions (if modified Jenkins_user)
Java code
[Java]View PlainCopy
    1. ####
    2. sudo chown-r admin/usr/lib/jenkins
    3. sudo chgrp-r admin/usr/lib/jenkins
    4. ####
    5. sudo chown-r admin/var/log/jenkins
    6. sudo chgrp-r admin/var/log/jenkins
    7. sudo chown-r admin/var/lib/jenkins
    8. sudo chgrp-r admin/var/lib/jenkins
    9. sudo chown-r admin/var/cache/jenkins
    10. sudo chgrp-r admin/var/cache/jenkins (this will appear 404 if not changed )

④. Start Jenkins
Java code
Sudo/sbin/service Jenkins Start
Or sudo service Jenkins start

Build Jenkins (Hudson) platform under Linux environment

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.