jenkins 服务(分布式master+slave) 搭建
整体步骤如下: copy一些基础软件mkdir -p /opt/CIPackage/cd /usrscp -r root@10.37.77.120:/usr/java ./cd /usr/localscp -r root@10.37.77.120:/usr/local/sonar ./cd /optscp -r root@10.37.77.120:/
jenkins master war 被tomcat 解压后(部署之后)的文件目录:
[root@jenkissitweb204 CI]# cd jenkinsslave/
[root@jenkissitweb204 jenkinsslave]#
[root@jenkissitweb204 jenkinsslave]# ll
total 344
-rw-rw-r-- 1 jenkins jenkins 346845 Nov 23 10:37 slave.jar
drwxrwxr-x 2 jenkins jenkins 4096 Nov 10 17:12 workspace
[root@jenkissitweb204 jenkinsslave]#
[root@jenkissitweb204 jenkinsslave]#
[root@jenkissitweb204 jenkinsslave]# cd ..
[root@jenkissitweb204 CI]# cd jenkinssonarprd/
[root@jenkissitweb204 jenkinssonarprd]#
[root@jenkissitweb204 jenkinssonarprd]# ll
total 500
-rw-r--r-- 1 root root 506256 Mar 31 2017 slave.jar
drwxr-xr-x 2 root root 4096 Oct 20 09:16 workspace
[root@jenkissitweb204 jenkinssonarprd]# cd ..
[root@jenkissitweb204 CI]# cd jenkins
[root@jenkissitweb204 jenkins]#
[root@jenkissitweb204 jenkins]#
[root@jenkissitweb204 jenkins]# ll
total 240
-rw-rw-r-- 1 jenkins jenkins 603 Dec 1 15:51 au.com.rayh.GlobalConfigurationImpl.xml
-rw-rw-r-- 1 jenkins jenkins 304 Dec 1 14:44 com.sic.plugins.kpp.provider.KPPKeychainsProvider.xml
-rw-rw-r-- 1 jenkins jenkins 348 Dec 1 14:44 com.sic.plugins.kpp.provider.KPPProvisioningProfilesProvider.xml
-rw-rw-r-- 1 jenkins jenkins 2371 Dec 1 15:51 config.xml
-rw-rw-r-- 1 jenkins jenkins 12388 Nov 20 19:21 credentials.xml
drwxrwxr-x 2 jenkins jenkins 4096 Nov 3 00:49 fingerprints
-rw-rw-r-- 1 jenkins jenkins 889 Dec 1 15:51 hudson.maven.MavenModuleSet.xml
-rw-rw-r-- 1 jenkins jenkins 159 Nov 30 10:05 hudson.model.UpdateCenter.xml
-rw-rw-r-- 1 jenkins jenkins 335 Dec 1 15:51 hudson.plugins.android_emulator.AndroidEmulator.xml
-rw-rw-r-- 1 jenkins jenkins 321 Dec 1 15:51 hudson.plugins.git.GitSCM.xml
-rw-rw-r-- 1 jenkins jenkins 370 Dec 1 15:51 hudson.plugins.git.GitTool.xml
-rw-rw-r-- 1 jenkins jenkins 1377 Dec 1 15:51 hudson.plugins.gradle.Gradle.xml
-rw-rw-r-- 1 jenkins jenkins 467 Dec 1 15:51 hudson.plugins.msbuild.MsBuildBuilder.xml
-rw-rw-r-- 1 jenkins jenkins 274 Dec 1 15:51 hudson.plugins.sonar.MsBuildSQRunnerInstallation.xml
-rw-rw-r-- 1 jenkins jenkins 224 Dec 1 15:51 hudson.plugins.sonar.SonarGlobalConfiguration.xml
-rw-rw-r-- 1 jenkins jenkins 203 Dec 1 15:51 hudson.plugins.sonar.SonarRunnerInstallation.xml
-rw-rw-r-- 1 jenkins jenkins 473 Dec 1 15:51 hudson.scm.CVSSCM.xml
-rw-rw-r-- 1 jenkins jenkins 4181 Dec 1 15:51 hudson.scm.SubversionSCM.xml
-rw-rw-r-- 1 jenkins jenkins 337 Dec 1 15:51 hudson.tasks.Ant.xml
-rw-rw-r-- 1 jenkins jenkins 188 Dec 1 15:51 hudson.tasks.Mailer.xml
-rw-rw-r-- 1 jenkins jenkins 335 Dec 1 15:51 hudson.tasks.Maven.xml
-rw-rw-r-- 1 jenkins jenkins 76 Dec 1 15:51 hudson.tasks.Shell.xml
-rw-rw-r-- 1 jenkins jenkins 215 Dec 1 15:51 hudson.triggers.SCMTrigger.xml
-rw------- 1 jenkins jenkins 1680 May 10 2016 identity.key.enc
-rw-rw-r-- 1 jenkins jenkins 159 Dec 1 15:51 jenkins.model.ArtifactManagerConfiguration.xml
-rw-rw-r-- 1 jenkins jenkins 138 Jul 11 2016 jenkins.model.DownloadSettings.xml
-rw-rw-r-- 1 jenkins jenkins 270 Dec 1 15:51 jenkins.model.JenkinsLocationConfiguration.xml
-rw-rw-r-- 1 jenkins jenkins 247 Dec 1 15:51 jenkins.mvn.GlobalMavenConfig.xml
-rw-rw-r-- 1 jenkins jenkins 4101 Dec 1 15:51 jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin.xml
-rw-rw-r-- 1 jenkins jenkins 169 Jul 11 2016 jenkins.security.QueueItemAuthenticatorConfiguration.xml
drwxrwxr-x 643 jenkins jenkins 36864 Dec 4 12:46 jobs
drwxrwxr-x 2 jenkins jenkins 4096 Mar 23 2017 kpp_upload
drwxrwxr-x 4 jenkins jenkins 4096 May 10 2016 logs
-rw-rw-r-- 1 jenkins jenkins 908 Nov 30 10:05 nodeMonitors.xml
drwxrwxr-x 14 jenkins jenkins 4096 Dec 1 14:45 nodes
-rw-rw-r-- 1 jenkins jenkins 255 Dec 1 15:51 org.jenkinsci.plugins.gitclient.JGitApacheTool.xml
-rw-rw-r-- 1 jenkins jenkins 243 Dec 1 15:51 org.jenkinsci.plugins.gitclient.JGitTool.xml
-rw-rw-r-- 1 jenkins jenkins 224 Dec 1 15:51 org.jvnet.hudson.plugins.port_allocator.PortAllocator.xml
drwxrwxr-x 40 jenkins jenkins 4096 Nov 30 10:04 plugins
-rw-rw-r-- 1 jenkins jenkins 129 Nov 30 10:05 queue.xml.bak
-rw-rw-r-- 1 jenkins jenkins 64 May 10 2016 secret.key
-rw-rw-r-- 1 jenkins jenkins 0 May 10 2016 secret.key.not-so-secret
drwx------ 4 jenkins jenkins 4096 Jun 30 2016 secrets
-rw-rw-r-- 1 jenkins jenkins 163 May 11 2016 sonar.xml
drwxrwxr-x 2 jenkins jenkins 4096 May 10 2016 userContent
drwxrwxr-x 47 jenkins jenkins 4096 Dec 2 17:41 users
drwxrwxr-x 2 jenkins jenkins 4096 Nov 15 15:27 workspace
[root@jenkissitweb204 jenkins]#
可见master 也是一台slave 只是 多了jenkins war包。
[root@sncdpredb05 war]# ll
总用量 1836
-rw-r--r-- 1 root root 2824 7月 15 2015 ColorFormatter.class
drwxr-xr-x 2 root root 4096 7月 15 2015 css
-rw-r--r-- 1 root root 1544 7月 15 2015 dc-license.txt
drwxr-xr-x 2 root root 4096 7月 15 2015 executable
-rw-r--r-- 1 root root 17542 7月 15 2015 favicon.ico
drwxr-xr-x 12 root root 4096 7月 15 2015 help
drwxr-xr-x 6 root root 4096 7月 15 2015 images
-rw-r--r-- 1 root root 1845 7月 15 2015 JNLPMain.class
-rw-r--r-- 1 root root 788 7月 15 2015 LogFileOutputStream$1.class
-rw-r--r-- 1 root root 586 7月 15 2015 LogFileOutputStream$2.class
-rw-r--r-- 1 root root 2197 7月 15 2015 LogFileOutputStream.class
-rw-r--r-- 1 root root 19577 7月 15 2015 Main.class
-rw-r--r-- 1 root root 1049 7月 15 2015 MainDialog$1$1.class
-rw-r--r-- 1 root root 1123 7月 15 2015 MainDialog$1.class
-rw-r--r-- 1 root root 2424 7月 15 2015 MainDialog.class
-rw-r--r-- 1 root root 512 7月 15 2015 Main$FileAndDescription.class
drwxr-xr-x 3 root root 4096 7月 15 2015 META-INF
-rw-r--r-- 1 root root 71 7月 15 2015 robots.txt
drwxr-xr-x 3 root root 4096 7月 15 2015 scripts
drwxr-xr-x 7 root root 4096 7月 15 2015 WEB-INF
-rw-r--r-- 1 root root 1761676 7月 15 2015 winstone.jar
[root@sncdpredb05 war]# cd ..
mkdir -p /opt/CIPackage/ (安装slave机器 直接 copy一些基础软件)
cd /usr
scp -r root@10.37.77.120:/usr/java ./
cd /usr/local
scp -r root@10.37.77.120:/usr/local/sonar ./
cd /opt
scp -r root@10.37.77.120:/opt/CI/ ./
cd /opt
scp -r root@10.37.77.120:/opt/CIPackage/ ./
CIPackage 目录下面:
总用量 326840
drwxr-xr-x 2 root root 4096 5月 25 2015 examples
-rw-r--r-- 1 root root 266089442 3月 20 2017 gitlab-ce-8.17.3-ce.0.el6.x86_64.rpm
drwxr-xr-x 4 root root 4096 11月 29 2011 javadoc
-rw-r--r-- 1 root root 68199289 8月 13 2015 jenkinssitold.war
drwxr-xr-x 2 root root 4096 6月 12 2016 plugin
drwxrwxr-x 6 1000 1000 4096 5月 8 2015 pytz-2014.4
drwxr-xr-x 5 sonar games 4096 5月 8 2015 requests-2.3.0
drwxrwxr-x 7 506 506 4096 5月 8 2015 setuptools-0.6c11
-rw-r--r-- 1 root root 340099 6月 9 2016 sonar.hpi
drwxr-xr-x 3 root root 4096 8月 13 2015 Test
-rw-r--r-- 1 root root 487 5月 25 2015 Test.class
-rw-r--r-- 1 root root 140 5月 25 2015 Test.java
[root@sncdpredb05 CIPackage]# cd p
plugin/ pytz-2014.4/
[root@sncdpredb05 CIPackage]# cd plugin/
[root@sncdpredb05 plugin]#
[root@sncdpredb05 plugin]# ll
总用量 3480
-rw-r--r-- 1 root root 133548 6月 12 2016 envinject.hpi
-rw-r--r-- 1 root root 3003464 6月 12 2016 jquery.hpi
-rw-r--r-- 1 root root 419614 6月 12 2016 sonar.hpi
[root@sncdpredb05 plugin]#
[root@sncdpredb05 opt]# ll
总用量 132
-rw-r--r-- 1 root root 52 7月 11 2016 a.sh
drwxr-xr-x 19 root root 4096 11月 13 16:52 CI
drwxr-xr-x 9 root root 4096 3月 21 2017 CIPackage
drwxr-xr-x 2 root root 4096 12月 10 2014 deljobs
drwxr-xr-x 3 root root 4096 9月 16 2015 epp
drwxr-xr-x 2 root root 4096 10月 29 2015 failedLog
drwxr-xr-x 3 root root 4096 5月 5 2014 IBM
drwxr-xr-x 9 root root 4096 2月 26 2015 JIRA_DATA
drwxr-xr-x 2 root root 4096 10月 9 2015 log
drwxr-xr-x 10 root root 4096 7月 11 2016 logs
drwx------. 2 root root 16384 5月 4 2014 lost+found
drwxr-xr-x 3 root root 4096 11月 10 2014 mysqldata
drwxr-xr-x 19 root root 4096 11月 11 2015 phonepadlogs
drwxr-xr-x 3 root root 4096 9月 25 2015 salt
drwxr-xr-x 2 root root 4096 9月 28 2016 SHELL
drwxr-xr-x 4 root root 4096 3月 20 2017 software
drwxr-xr-x 3 root root 4096 10月 16 2014 SONAR
drwxr-xr-x 7 root root 4096 1月 26 2015 sources
drwxr-xr-x 1003 root root 24576 8月 8 2016 svntest
drwxrwx--x 3 root root 4096 5月 5 2014 symantec
drwxr-xr-x 4 root root 4096 9月 27 2016 test
-rw-r--r-- 1 root root 9 10月 8 2015 test.txt
drwxr-xr-x 2 root root 4096 7月 17 11:31 tmp
drwxr-xr-x 3 root root 4096 2月 9 2017 zabbix
[root@sncdpredb05 usr]# cd java
[root@sncdpredb05 java]# ll
总用量 642024
lrwxrwxrwx 1 root root 16 10月 16 2014 default -> /usr/java/latest
drwxr-xr-x 9 502 502 4096 5月 20 2013 java
-rw-r--r-- 1 root root 188364800 1月 22 2015 java.tar
drwxr-xr-x 7 root root 4096 10月 16 2014 jdk1.6.0_43
drwxr-xr-x 8 uucp 143 4096 12月 19 2014 jdk1.7.0_75
drwxr-xr-x 8 uucp 143 4096 4月 11 2015 jdk1.7.0_79
drwxr-xr-x 8 uucp 143 4096 6月 9 2015 jdk1.8.0_51
-rw-r--r-- 1 root root 142245547 1月 22 2015 jdk-7u75-linux-x64.tar.gz
-rw-r--r-- 1 root root 153512879 8月 13 2015 jdk-7u79-linux-x64.tar.gz
-rw-r--r-- 1 root root 173281904 8月 13 2015 jdk-8u51-linux-x64.tar.gz
lrwxrwxrwx 1 root root 21 10月 16 2014 latest -> /usr/java/jdk1.6.0_43
[root@sncdpredb05 java]#
usr/local/sonar 目录:
slave 上进行安装 maven
总用量 48
drwxr-xr-x. 2 root root 4096 6月 28 2011 bin
drwxr-xr-x. 2 root root 4096 6月 28 2011 etc
drwxr-xr-x. 2 root root 4096 6月 28 2011 games
drwxr-xr-x 6 root root 4096 10月 27 13:20 git
drwxr-xr-x. 2 root root 4096 6月 28 2011 include
drwxr-xr-x. 2 root root 4096 6月 28 2011 lib
drwxr-xr-x. 2 root root 4096 6月 28 2011 lib64
drwxr-xr-x. 2 root root 4096 6月 28 2011 libexec
drwxr-xr-x. 2 root root 4096 6月 28 2011 sbin
drwxr-xr-x. 5 root root 4096 5月 4 2014 share
drwxr-xr-x 3 root root 4096 12月 19 2016 sonar
drwxr-xr-x. 2 root root 4096 6月 28 2011 src
[root@sncdpreapp60 local]# cd sonar
[root@sncdpreapp60 sonar]#
[root@sncdpreapp60 sonar]#
[root@sncdpreapp60 sonar]# ll
总用量 5032
drwxr-xr-x 6 root root 4096 12月 19 2016 apache-maven-3.0.5
-rw-r--r-- 1 root root 5144659 12月 19 2016 apache-maven-3.0.5-bin.tar.gz
[root@sncdpreapp60 sonar]#
然后是一些软件工具安装如 svn, git, node 以及用户名和密码的存储
安装svn 并记录 用户名密码
yum install subversion
yum install apr-util
yum install openssl
cd /opt/CI
svn log -r head https://a.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
svn log -r head https://b.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
svn log -r head https://c.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
svn log -r head https://d.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
svn log -r head https://e.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
svn log -r head https://f.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
svn log -r head https://g.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
svn log -r head https://h.svncode.cnsuning.com/svn/myproject --username svnadmin --password ******
npm环境变量设置:
进入每台进去,安装node,解压即可
rm -rf /opt/CI/node-v6.9.1-linux-x64
tar -zxvf /opt/CI/node-v6.9.1-linux-x64.tar.gz
vi ~/.npmrc
#registry=http://10.37.55.28:4873/
registry=http://snpm.cnsuning.com/
git安装:
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
进入git解压目录
rm -rf /opt/CIPackage/git-2.10.2
tar -zxvf /opt/CIPackage/git-2.10.2.tar.gz
cd /opt/CIPackage/git-2.10.2
make prefix=/usr/local/git all
sudo make prefix=/usr/local/git install
soa jar包特殊操作
cd /
mkdir -p /data/jenkins_node/workspace
10.27.88.40 root ******
scp -r root@10.27.88.40:/opt/jenkinsslave/workspace/soa_jar /data/jenkins_node/workspace/
设置环境变量:
vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_75
export PATH=$JAVA_HOME/bin:$PATH
export MAVEN_HOME=/usr/local/sonar/apache-maven-3.0.5
export PATH=$MAVEN_HOME/bin:$PATH
export ANT_HOME=/opt/CI/apache-ant-1.9.4
export PATH=$ANT_HOME/bin:$PATH
export LANG="zh_CN.UTF-8"
export NODE_HOME=/opt/CI/node-v6.9.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin/
export GULP_HOME=/opt/CI/node-v6.9.1-linux-x64/lib/node_modules/gulp
export PATH=$PATH:$GULP_HOME/bin/
export MAVEN_OPTS="-Dfile.encoding=UTF-8 -XX:NewSize=128m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps"
export PATH=/usr/local/git/bin:$PATH
source /etc/profile
vim ~/.bashrc
export JAVA_HOME=/usr/java/jdk1.7.0_75
export PATH=$JAVA_HOME/bin:$PATH
export MAVEN_HOME=/usr/local/sonar/apache-maven-3.0.5
export PATH=$MAVEN_HOME/bin:$PATH
export ANT_HOME=/opt/CI/apache-ant-1.9.4
export PATH=$ANT_HOME/bin:$PATH
export LANG="zh_CN.UTF-8"
export NODE_HOME=/opt/CI/node-v6.9.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin/
export GULP_HOME=/opt/CI/node-v6.9.1-linux-x64/lib/node_modules/gulp
export PATH=$PATH:$GULP_HOME/bin/
export MAVEN_OPTS="-Dfile.encoding=UTF-8 -XX:NewSize=128m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps"
export PATH=/usr/local/git/bin:$PATH
~
source ~/.bashrc
更多推荐
所有评论(0)