#!/bin/bash
#
# Copyright (c) 2014-2015 Michael Dichirico (https://github.com/mdichirico)
# This software/script is released under the terms of the MIT license (http://en.wikipedia.org/wiki/MIT_License).
#
# I wrote this shell script to use Jenkins
# Then run this script by following the INSTRUCTIONS FOR USE that follows.
#
# INSTRUCTIONS FOR USE:
# 1. Copy this shell script to your home directory or the /tmp directory.
# 2. Make it executable with the following command:
# chmod a+x setup-jenkins-on-cent-os-7.sh
# 3. Execute the script as a sudo user:
# sudo ./setup-jenkins-on-cent-os-7.sh
#
# It's important to point out that this script assumes that none of the binaries
# that are to be installed are already present on the target server. If you already
# have the EPEL repository installed on your target server, you should first remove it
# by following the instructions in this link:
#
# http://www.cyberciti.biz/faq/centos-redhat-fedora-linux-remote-yum-repo-configuration/
#
# If you already have Jenkins installed on your target server, please be aware that
# the user 'Anonymous' needs to have ALL privileges in order to successfully plugins
# as part of this shell script. After running this shell script, you can return
# the anonynous user to have less privileges.

# Since this script needs to be runnable on either CentOS7 or CentOS6, we need to first
# check which version of CentOS that we are running and place that into a variable.
# Knowing the version of CentOS is important because some shell commands that had
# worked in CentOS 6 or earlier no longer work under CentOS 7
RELEASE=`cat /etc/redhat-release`
isCentOs7=false
SUBSTR=`echo $RELEASE|cut -c1-22`

if [ "$SUBSTR" == "CentOS Linux release 7" ]
then
isCentOs7=true
fi

if [ "$isCentOs7" == true ]
then
echo "I am CentOS 7"
fi

CWD=`pwd`

# Let's make sure that yum-presto is installed:
sudo yum install -y yum-presto

# Let's make sure that mlocate (locate command) is installed as it makes much easier when searching in Linux:
sudo yum install -y mlocate

# Although not needed for Jenkins, I like to use vim, so let's make sure it is installed:
sudo yum install -y vim

# The Jenkins setup makes use of wget, so let's make sure it is installed:
sudo yum install -y wget

# Let's make sure that we have the EPEL and IUS repositories installed.
# This will allow us to use newer binaries than are found in the standard CentOS repositories.
# http://www.rackspace.com/knowledge_center/article/install-epel-and-additional-repositories-on-centos-and-red-hat
sudo yum install -y epel-release
if [ "$isCentOs7" == true ]
then
sudo wget -N http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-13.ius.centos7.noarch.rpm
sudo rpm -Uvh ius-release*.rpm
else
sudo wget -N http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-13.ius.centos6.noarch.rpm
sudo rpm -Uvh ius-release*.rpm
fi

# Let's make sure that openssl is installed:
sudo yum install -y openssl

# Let's make sure that curl is installed:
sudo yum install -y curl

# Jenkins on CentOS requires Java, but it won't work with the default (GCJ) version of Java. So, let's remove it:
sudo yum remove -y java

# install the OpenJDK version of Java 7:
sudo yum install -y java-1.7.0-openjdk

# Jenkins uses 'ant' so let's make sure it is installed:
sudo yum install -y ant

# Let's now install Jenkins:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install -y jenkins

# Let's start Jenkins
if [ "$isCentOs7" == true ]
then
sudo systemctl start jenkins
else
sudo service jenkins start
fi

# Jenkins runs on port 8080 by default. Let's make sure port 8080 is open:
if [ "$isCentOs7" == true ]
then
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
else
sudo iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
sudo service iptables save
sudo service iptables restart
fi

# Let's make sure that git is installed since Jenkins will need this
sudo yum install -y git

# Install phpDox, which is needed by Jenkins.
# https://github.com/theseer/phpdox
sudo wget -N http://phpdox.de/releases/phpdox.phar
sudo chmod +x phpdox.phar
sudo mv phpdox.phar /usr/bin/phpdox

# Install 'composer':
sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer

# Now that composer is installed, let's install PHPUnit and its associated packages:
sudo composer global require "phpunit/phpunit=4.3.*"
sudo composer global require "phpunit/php-invoker"
sudo composer global require "phpunit/dbunit": ">=1.2"
sudo composer global require "phpunit/phpunit-selenium": ">=1.2"

# PHP CodeSniffer:
sudo composer global require "squizlabs/php_codesniffer"

sudo composer update

# We need to increase the memory limit used by PHP:
sudo sed -i 's/memory_limit = 128M/memory_limit = 2048M/g' /etc/php.ini

# Let's update Jenkins to use the PHP tools that we had installed with Composer:
sudo curl -L http://updates.jenkins-ci.org/update-center.json | sed '1d;$d' | curl -X POST -H 'Accept: application/json' -d @- http://localhost:8080/updateCenter/byId/default/postBack

sudo wget -N http://localhost:8080/jnlpJars/jenkins-cli.jar

sudo java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin checkstyle cloverphp crap4j dry htmlpublisher jdepend plot pmd violations xunit

# Install the PHP-Jenkins job template:
sudo wget -N http://localhost:8080/jnlpJars/jenkins-cli.jar
sudo curl -L https://raw.githubusercontent.com/sebastianbergmann/php-jenkins-template/master/config.xml | sudo java -jar jenkins-cli.jar -s http://localhost:8080 create-job php-template

# Lastly, let's install the plugins needed in Jenkins to connect to Github and get a fairly well-running Jenkins installation:
cd /var/lib/jenkins/plugins
sudo rm -R -f ant
sudo rm -R -f credentials
sudo rm -R -f deploy
sudo rm -R -f git-client
sudo rm -R -f git
sudo rm -R -f github-api
sudo rm -R -f github-oauth
sudo rm -R -f github
sudo rm -R -f gcal
sudo rm -R -f google-oauth-plugin
sudo rm -R -f greenballs
sudo rm -R -f javadoc
sudo rm -R -f ldap
sudo rm -R -f mailer
sudo rm -R -f mapdb-api
sudo rm -R -f maven-plugin
sudo rm -R -f external-monitor-job
sudo rm -R -f oauth-credentials
sudo rm -R -f pam-auth
sudo rm -R -f scm-api
sudo rm -R -f ssh-agent
sudo rm -R -f ssh-credentials
sudo rm -R -f ssh-slaves
sudo rm -R -f subversion
sudo rm -R -f translation
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin ant
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin credentials
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin deploy
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin git-client
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin git
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin github-api
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin github-oauth
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin github
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin gcal
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin google-oauth-plugin
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin greenballs
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin javadoc
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin ldap
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin mailer
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin mapdb-api
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin maven-plugin
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin external-monitor-job
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin oauth-credentials
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin pam-auth
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin scm-api
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin ssh-agent
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin ssh-credentials
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin ssh-slaves
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin subversion
sudo java -jar $CWD/jenkins-cli.jar -s http://localhost:8080/ install-plugin translation

# Be sure to change ownership of all of these downloaded plugins to jenkins:jenkins
sudo chown jenkins:jenkins *.hpi
sudo chown jenkins:jenkins *.jpi

# Restart Jenkins to implement the new plugins:
cd $CWD

# Let's start Jenkins
sudo java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart

# Update the 'locate' database:
sudo updatedb

echo ""
echo "Finished with setup"
echo ""
echo "You can visit your Jenkins installation at the following address (substitute 'localhost' if necessary):"
echo " http://localhost:8080"
echo ""
echo "Although Jenkins should be installed at this point, it hasn't been secured. See this link:"
echo "https://wiki.jenkins-ci.org/display/JENKINS/Standard+Security+Setup"
echo ""

Install Jenkins 2.1.36 and openjdk 1.7.0 on centos 7的更多相关文章

  1. brew install Jenkins

    Chens-MacBook-Pro:Downloads chenqing$ brew install jenkins ==> Downloading http://mirrors.jenkins ...

  2. How to install Jenkins on CentOS 7

    How to install Jenkins on CentOS 7 on March 3, 2018 by AmirLeave a comment Introduction Jenkins is a ...

  3. How to install Wordpress 4.0 on CentOS 7.0

    This document describes how to install and configure Wordpress 4.0 on CentOS 7.0. WordPress started ...

  4. 【问题】报错[CRITICAL] Rendering SLS 'base:minions.install' failed: Jinja variable 'list' object has no element 0

    1.报错[CRITICAL] Rendering SLS 'base:minions.install' failed: Jinja variable 'list' object has no elem ...

  5. 安装xlrd包的时候,总是报错:ERROR: Could not install packages due to an EnvironmentError: HTTPConnectionPool (host='127.0.0.1', port=8888):。。。

    安装xlrd包的时候,总是报错:ERROR: Could not install packages due to an EnvironmentError: HTTPConnectionPool (ho ...

  6. Email-Ext Plugin install ------ Jenkins Plugins

    一.基本信息 1. Email-Ext Plugin功能简介 支持Jenkins邮件发送时,自定义邮件内容功能.详情可以查看jenkins的wiki : https://wiki.jenkins-ci ...

  7. Install Jenkins Slave as Windows Service

    https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service SC 直接创建windows s ...

  8. pip install psutil出错-You are using pip version 10.0.1, however version 18.0 is available.

    今天想用python代替shell做运维相关的事,写代码都是在本机,调试在服务器上 C:\Users\0>pip install psutilRequirement already satisf ...

  9. OpenJDK换为JDK(CentOS)

    说明:应该来说没必要非把OpenJDK卸载掉,只要让$PATH中我们安装的jdk的目录较OpenJDK所在的/usr/bin先出现就好了:简言之跳过下边的第一步直接从第二步开始更科学一些. 1.卸载O ...

随机推荐

  1. 判断是pc端登录还是移动端登录

    java判断 https://blog.csdn.net/qq_32657581/article/details/71405838 https://zhidao.baidu.com/question/ ...

  2. vue——做了一个幼稚的小页面

    我的小花花没有转起来,不开心  ̄へ ̄

  3. HDU 4143 A Simple Problem 分解因式

    求一个最小的正整数x,使得(y + x) (y - x) = n成立 考虑一下n的分解因式. 可能会想到枚举n的约数,那么a * b = n成立,取最小的x即可 但是要枚举到n / 2,这样会超时. ...

  4. 使用nasm和clang

    nasm编译 nasm -f macho64 --prefix _ demo.asm # --prefix是为gobal的标签添加前缀, 链接时根据的都是以_开头的 clang编译 clang tes ...

  5. SpringBoot | 第十章:Swagger2的集成和使用

    前言 前一章节介绍了mybatisPlus的集成和简单使用,本章节开始接着上一章节的用户表,进行Swagger2的集成.现在都奉行前后端分离开发和微服务大行其道,分微服务及前后端分离后,前后端开发的沟 ...

  6. webpack 3 优化

    编译时间太长 项目为多页面应用时,编译的时候每个入口都会读取依赖的路径,所以入口越多,会导致编译越慢 公用库提取 除了公用的框架(如 Vue.React)以外,不同页面所需要的第三方库可能不一样,而且 ...

  7. C#实现对EXCEL指定单元格进行操作

    using System; using System.Collections.Generic; using System.Text; using Microsoft.Office.Interop.Ex ...

  8. Google,真的要离我们而去吗?

    Google,真的要离我们而去吗? 好怀念,真正要解决问题,还得搜google!

  9. 添加SAP_ALL权限

    更新usr04,ust04,usrbf2这三张表 REPORT ZTESTCREATEUSER. data: l_USR04 LIKE USR04 , l_UST04 LIKE UST04 , l_P ...

  10. Vue日历

    Vue生成日历,根据返回值将日期标红 HTML: <h1>CSS 日历</h1> <div id="calendar"> <div cla ...