Thursday, May 3, 2018

Jenkins installation as a service using .war files on a Virtual Machine


Steps to bring up a Jenkins instance on a centOS7 instance


1. Bringup a VM and & Install any linux distro of your preference. In this case, I'm using CentOS7.
2. Install supported Jenkins v1.624 wget https://updates.jenkins-ci.org/download/war/1.624/jenkins.war.
3. Install Java 7 yum install java-1.7.0-openjdk (https://www.atlantic.net/cloud-hosting/how-to-install-java-jre-jdk-centos-7/) and configure the OS to use java 1.7 by default
4. Set environment (export $JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.171-2.6.13.0.el7_4.x86_64" | sudo tee -a /etc/profile;  echo 'export $JRE_HOME=/usr/lib/jvm/jre/' | tee -a /etc/profile; source /etc/profile)
5. Install Jenkins (cd ~; java -jar jenkins.war)
6. Configure Jenkins as a service ( cd /etc/systemd/system; vi jenkins.service and add below lines to it.

[Unit]
Description=Jenkins Service
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/bin/java -jar /usr/local/bin/jenkins.war
Restart=on-abort

[Install]
WantedBy=multi-user.target

7. Start the Jenkins Service (systemctl daemon-reload; systemctl start jenkins.service)


Establishing trust between Jenkins and other applications

Get the certificate of the application (in this case it's named as 'ccm.cer')
  1. export $JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.171-2.6.13.0.el7_4.x86_64" | sudo tee -a /etc/profile
  2. echo 'export $JRE_HOME=/usr/lib/jvm/jre/' | tee -a /etc/profile
  3. source /etc/profile

  1. echo $JRE_HOME
  2. echo $JAVA_HOME

  1. java InstallCert 10.193.180.190
  2. cp jssecacerts $JAVA_HOME/lib/security
  3. cp jssecacerts ~/.keystore
  4. keytool -list -alias 10.193.180.190-1
  5. Cd /usr/lib/jvm/jre-1.8.0-openjdk/lib/security
  6. keytool -importcert -file /root/ccm.cer -keystore cacerts -alias 10.193.180.190-1
  7. keytool -list -alias 10.193.180.190-1
  8. reboot
  9. systemctl status jenkins.service
  10. systemctl start jenkins.service
  11. systemctl status jenkins.service
  12. java SSLPoke 10.193.180.190 443


No comments:

Post a Comment