Jenkins-1

Jenkins-1 on Ubuntu 18.04

  1. Install Java: sudo apt install default-jre (This is not good, as this will install J)
  2. Go to Jenkins.io to download Generic Java Package (jenkins.war) file.
  3. java -jar jenkins.war
    However, Jenkins will not start up correctly because of an incorrect Java version. If you look in /var/log/jenkins/jenkins.log, the following error message will be there:

    Jenkins requires Java 8, but you are running 10.0.1+10-Ubuntu-3ubuntu1 from /usr/lib/jvm/java-11-openjdk-amd64
    java.lang.UnsupportedClassVersionError: 54.0
        at Main.main(Main.java:128)
    

    As the error message says, Java 8 is needed instead of the Java version that is present on the system. To fix this, install Java 8:

    sudo apt-get install openjdk-8-jdk
    

    For Jenkins to be able to use the installed Java 8, make Java 8 the default version of Java:

    sudo update-alternatives --config java
    

    In the dialog that appears, select the version that has /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java as its path, and the restart Jenkins (sudo service jenkins restart).

    After this, Jenkins should start up normally. You can check that it is the case by visiting https://zangchuantao.com:8080, and by looking at the Jenkins logs at /var/log/jenkins/jenkins.log and making sure that there are no fatal errors reported there. Have fun with automation!

  4. Jenkins offline issue. This is due to SSL certificate.
    Fix: open the file ~/.jenkins/hudson.model.UpdateCenter.xml, replace https with http. Restart Jenkins by 192.168.1.98:8080/restart.
  5. Create admin account, psw. Install Jenkins plugin, rebuilder and safe restart.
  6. Update Jenkins Global Security, Matrix based security, add user 'admin' and authorize all permissions to it.
  7. Create another user "tester01", and assign it all permissions except the administration in Global Security Settings.

Git Operations

  1. Git already installed.
  2. git config --global user.name "chuantao"
  3. git config --global user.email "your email, no need for real"
  4. Generate certificate by running command:
    ssh-keygen -t rsa -C "your email".

    The public/private key will be in ~/.ssh/ and later the public key's content will be added to github keys.

  5. Login to github.com with your own account. Settings ->SSH and GPG keys -> New SSH Key, past public contents here and save. Test this by run
    ssh git@github.com

Maven

  1. Got to maven.apache.org to download maven. Choose bin.zip file to download binary zip archive.
  2. unzip the download file to /home/chuantao/apache-maven-3.5.4 and add this path to system environment:
    sudo nano /etc/environment, add two lines below:
    export MAVEN_HOME=/home/chuantao/apache-maven-3.5.4
  3. run mvn -version to check whether mvn has been correctly set. Set JAVA_HOME to correct value if it reports JAVA_HOME setting error. After setting, source /etc/environment to update it. Note, this file contains path and will override path by removing maven path. So after this, user need to run /etc/profile again to add maven path back ". /etc/profile".
    sudo nano /etc/environment

Tomcat

  1. Go to tomcat.apache.org to download Binary distribution Core zip file.Unzip it.
  2. Cd to the folder, sudo chmod a+x -R *
  3. update server.xml to change port from 8080 to 8090,
  4. sh bin/startup.sh
  5. open browser, 192.168.1.98:8090

Until now, we have set up a Linux machine with Java, Maven, Tomcat, Git. Next we add this machine to Jenkins.

Leave a Reply

Your email address will not be published.