#!/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. 012 Integer to Roman 整数转换成罗马数字

    给定一个整数,将其转为罗马数字.输入保证在 1 到 3999 之间. 详见:https://leetcode.com/problems/integer-to-roman/description/ cl ...

  2. View转换为Bitmap及getDrawingCache

    View组件显示的内容可以通过cache机制保存为bitmap, 使用到的api有 void  setDrawingCacheEnabled(boolean flag),    Bitmap  get ...

  3. Unity UGUI按钮添加点击事件

    1. 可视化创建及事件绑定 # 1 : 通过 Hierarchy 面板创建 UI > Button. 2 : 创建一个脚本 TestClick.cs, 定义了一个 Click 的 public ...

  4. 【Java】在eclipse中使用gradle进行项目构建 入门篇

    ##Gradle的安装与配置- Gradle 是以 Groovy 语言为基础,面向Java应用为主,基于DSL(领域特定语言)语法的自动化构建工具. 系统环境变量中添加gradle 前往官网下载Com ...

  5. docker的卸载方法

    卸载: 1.查询docker安装过的包: yum list installed | grep docker 2.删除安装包: yum remove docker-ce.x86_64 ddocker-c ...

  6. Rspec基本语法

    引用链接:http://reverocean.iteye.com/blog/1489957 1. describe和context describe和context方法用来组织相关的行为example ...

  7. *.rpm is not signed解决

    1.# yum install qemu*报错如下:Package qemu-kvm-tools-0.12.1.2-2.113.el6.x86_64.rpm is not signed2.解决# vi ...

  8. ABAP ICON

    1.输出图标的3种方法 WRITE: / '@09@'. "id WRITE: / icon_yellow_light. "name WRITE: / '@S_TL_Y@'. &q ...

  9. WebClient实现文件下载详解(二)

    .Net2.0中新增了很多组件,WebClient就是其中一个,功能也很强大,今天拿WebClient做了一个小实验,只用到了一些很简单的功能就可以实现以前不好实现的功能,很方便. 简单介绍一下Web ...

  10. C,通信,多线程,数据库小练习——在线电子词典第一版

    #ifndef FILE_H #define FILE_H #include<stdio.h> #include<sys/types.h> #include<sys/so ...