Jenkins is a CI (continuous integration) server. It can be a very handy tool for developers. In this tutorial, I will show you how to install and setup Jenkins.<\/p>\n
First off, we need to add the key and source list to apt. We can do this by executing the following commands.<\/p>\n
wget -q -O - http:\/\/pkg.jenkins-ci.org\/debian\/jenkins-ci.org.key | apt-key add -\r\necho deb http:\/\/pkg.jenkins-ci.org\/debian binary\/ > \/etc\/apt\/sources.list.d\/jenkins.list\r\napt-get update\r\n<\/code><\/pre>\nNext, install Jenkins. Note that this can take quite some time.<\/p>\n
apt-get install jenkins\r\n<\/code><\/pre>\nStep 2: Accessing Jenkins<\/h3>\n
Time to configure Jenkins. By default, Jenkins runs on port 8080, so you can access it by visiting\u00a0http:\/\/[SERVER_IP]:8080<\/code>\u00a0in your web browser.<\/p>\nBy default, everyone has access to Jenkins. You may want to add a password so that not everyone can use it. To add a password, go to “Manage Jenkins” (left). You will see a warning; click on “Setup Security” next to it.<\/p>\n
When asked, choose “Jenkins’s own user database” and “Matrix-based security”. Anonymous should only have “Read”. Save these settings.<\/p>\n
Jenkins will ask you to sign up now. Choose a username, password, email address, and full name. Click “Sign up”. You’ll now be the administrator of your Jenkins server.<\/p>\n
Step 3: Using Jenkins on port 80<\/h3>\n
If you want to be able to use a domain name with your Jenkins server, but you don’t want people to have to type “:8080” after it each time, we can set up iptables so all traffic from port 80 will be redirected to port 8080. Add the following iptables rules.<\/p>\n
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT\r\niptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT\r\niptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080\r\n<\/code><\/pre>\nMake sure to save and restart iptables.<\/p>\n
service iptables save\r\nservice iptables restart\r\n<\/code><\/pre>\nStep 3: Adding a job<\/h3>\n
In Jenkins, you can have multiple jobs; that basically means that you have multiple projects that you can build. To add a job, click “New Job” (you have to be logged in). From here, it should be pretty straight-forward; if you have a Maven project, click Maven of course!<\/p>\n
Step 4: Using Apache and SSL for Jenkins<\/h3>\n
If you want to use Apache as a reverse proxy, that’s easy with Jenkins!<\/p>\n
You need the following Apache modules to be installed.<\/p>\n
a2enmod proxy\r\na2enmod proxy_http\r\n<\/code><\/pre>\nNow add a virtual host.<\/p>\n
<VirtualHost *:443>\r\n ServerName jenkins.domain\r\n ServerAlias www.jenkins.domain\r\n\r\n SSLEngine On\r\n SSLCertificateFile \/etc\/apache2\/ssl\/crt\/jenkins.domain.crt\r\n SSLCertificateKeyFile \/etc\/apache2\/ssl\/key\/jenkins.domain.key\r\n\r\n ProxyRequests Off\r\n ProxyPass \/ http:\/\/localhost:8080\/\r\n ProxyPassReverse \/ http:\/\/localhost:8080\/\r\n ProxyPassReverse \/ http:\/\/jenkins.host\/\r\n <Proxy http:\/\/localhost:8080\/*>\r\n Order allow,deny\r\n Allow from all\r\n <\/Proxy>\r\n ProxyPreserveHost on\r\n<\/VirtualHost>\r\n<\/code><\/pre>\nThis will allow you to use Jenkins with SSL.<\/p>\n
Step 5: Installing plugins<\/h3>\n
There are a lot of plugins for Jenkins; they allow you to do a lot of things. To install a plugin, go to “Manage Jenkins” and then click on “Manage Plugins”. This area will allow you to install plugins.<\/p>\n
Step 6: Increase Maven’s memory<\/h3>\n
Although this is slightly off-topic, I still thought I’d share how to increase the memory assigned to Maven. You need to edit\u00a0MAVEN_OPTS<\/code>. For example:<\/p>\nset MAVEN_OPTS=\"-Xmx1024m -XX:MaxPermSize=128m\"<\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[245,247],"manual_kb_tag":[490],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2998"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2998"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2998\/revisions"}],"predecessor-version":[{"id":2999,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2998\/revisions\/2999"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2998"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2998"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}