Jenkins Notes

Russell Bateman
March 2017
last update:



I discovered that last October I had apparently installed Ubuntu Xenial (16.04LTS) in a VirtualBox on my Fedora 22 host. This saved me from having to erect a new VM on which to run Jenkins. I whipped out my Jenkins notes from Jenkins VM for Continuous Deployment, and started in. I had to install:

  1. python-software-properties
  2. git (2.7.4)
  3. ant (1.9.6) and Maven (3.3.9) were already good
  4. Java is already good (OpenJDK 1.8.0_121)

At this point, I had to abandon my notes which are too old. I began using How to Install Jenkins Automation Service with Apache on Ubuntu 16.04. Continuing...

  1. add-apt-repository ppa:openjdk-r/ppa
  2. apt-get update
  3. wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | apt-key add -
  4. echo 'deb https://pkg.jenkins.io/debian-stable binary/' | tee -a /etc/apt/sources.list
  5. apt-get update
  6. apt-get install jenkins
  7. systemctl start jenkins (notice that Debian has gone to systemctl too)
  8. netstat -plntu (to see Jenkins running—it will be a Java process)

Next up, install and configure Apache httpd as a reverse proxy for Jenkins:

  1. apt-get install apache2
  2. a2enmod proxy
  3. a2enmod proxy_http
  4. cd /etc/apache2/sites-available/
  5. cp 000-default.conf jenkins.conf (to get a head start because I don't have copy and paste)
  6. vim jenkins.conf —I did the following (xenial is my server's hostname):
    #netstat -plntu
    <Virtualhost *:80>
        ServerName            xenial.jenkins.id
        ProxyRequests         Off
        ProxyPreserveHost     On
        AllowEncodedSlashes   NoDecode
    
        <Proxy http://localhost:8080/*>
          Order deny,allow
          Allow from all
        </Proxy>
    
        ProxyPass         / http://localhost:8080/ nocanon
        ProxyPassReverse  / http://localhost:8080/
        ProxyPassReverse  / http://xenial.jenkins.id/
    </Virtualhost>
    
  7. a2ensite jenkins
  8. systemctl restart apache2
  9. systemctl restart jenkins
  10. Verify that Jenkins is on port 8080 and Apache on port 80:
    Proto Recv-Q Send-Q Local Address  Foreign Address  State   PID/Program name
    tcp6  0      0      :::8080        :::*             LISTEN  23033/java
    tcp6  0      0      :::80          :::*             LISTEN  22907/apache2
    

Configuring Jenkins, the domain name is xenial.jenkins.id. However, this is on a VM, so I tried to browse to http://10.0.2.15:8080. This didn't work either.

The only thing I got working was to go to localhost:8080 in a browser in the VM. It came up and I continue with the installation:

  1. cat /var/lib/jenkins/secrets/initialAdminPassword (and I got the long, goopy number)
  2. Paste in the long, goopy number as password for Administrator.
  3. I walked the Customize Jenkins path a bit.
    1. I installed the suggested plug-ins, then created the first administrative user, russ.
    2. I wanted to install some other plug-ins, but it didn't come back to the option.

Now my problem is reaching this from elsewhere (that is, besides the VM itself). I solved this by dropping xenial, then changing the VirtualBox Network setting from NAT to Bridged.

(Incidentally, as soon as I rebooted in Bridged mode, then copy-and-paste became an option between my Fedora 22 host and xenial VM.)

Relaunching, I discovered that the IP address changed, but I was able to reach it from a browser on my Fedora 22 host using the URL below. I had already made an entry in /etc/hosts:

10.10.8.99	xenial		xenial.jenkins.id
http://xenial.jenkins.id:8080/

However, when I added an admin user, russ, to Jenkins, it did not take it and now I've lost the administrator password. I was able to get that back the same way I got it (from the Jenkins secrets). I got signed in again (on xenial), then changed the admin password to my own. Then I was able to log in from my Fedora 22 host.

From a browser on my Fedora 22 host, I clicked Manage Jenkins, then Configure Global Security. Then I continued the installation:

  1. I chose Matrix-based security.
  2. I added the admin user as a User/group.
  3. I clicked the little icon at the right end of admin to give it all privileges.
  4. I gave user Anonymous read privileges.
  5. I clicked Save.

Just for fun, I continued the tutorial to test a simple automation job. To do that, I had to get out of the Manage Jenkins page and back to the simple dashboard. I clicked New Item, created a job and ran the build. It all worked. It was a great tutorial.