My linux world » Jenkins

Jenkins


Prerequiste

I assume that you have a Centos installation.

Installation

You can copy/paste this script and use it to configure automatically your server.

  1. #!/bin/bash
  2.  
  3. echo "import repository jenkins"
  4. sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
  5. sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
  6.  
  7. echo "install java and jenkins"
  8. dnf -y install java-1.8.0-openjdk jenkins
  9.  
  10.  
  11. echo "configure httpd (create /etc/httpd/conf.d/jenkins.conf)"
  12. cat > /etc/httpd/conf.d/jenkins.conf << "EOF"
  13. ProxyPreserveHost On
  14. Proxypass /jenkins http://localhost:8080/jenkins
  15. Proxypassreverse /jenkins http://localhost:8080/jenkins
  16. ProxyRequests Off
  17. EOF
  18.  
  19.  
  20. echo "configure jenkins"
  21.  
  22. #change home directory
  23. mkdir -p /opt/jenkins_home
  24. chown jenkins:jenkins /opt/jenkins_home -R
  25. sed -i "s/^\(JENKINS_HOME=\).*/\1\"\/opt\/jenkins_home\"/" /etc/sysconfig/jenkins
  26.  
  27. #configure jenkins prefix tu run begin apache:
  28. sed -i "s/^\(JENKINS_ARGS=\).*/\1\"--prefix=\/jenkins\"/" /etc/sysconfig/jenkins
  29.  
  30. #Security-Enhanced Linux (SE-Linux)
  31. setsebool -P httpd_can_network_connect true
  32.  
  33. echo "start jenkins"
  34. systemctl restart httpd.service
  35. systemctl start jenkins.service
  36.  
  37.  
  38. myip=`hostname -I`
  39. echo "Now meet you here: http://$myip/jenkins"
  40.  
  41.  

That’s all 🙂


Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.