jenkins 安装部署

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jenkins 安装部署相关的知识,希望对你有一定的参考价值。

  1. 下载

Jdk8jdk-8u121-linux-x64.tar.gz

Tomcat9wget http://apache.fayea.com/tomcat/tomcat-9/v9.0.0.M20/bin/apache-tomcat-9.0.0.M20.tar.gz

Anthttps://www.apache.org/dist/ant/binaries/apache-ant-1.10.1-bin.tar.gz

Mavenwget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz

Jenkinswget http://mirrors.jenkins-ci.org/war/latest/jenkins.war

 

 

  1. Linux环境下安装

  2. 1   下载并安装JDK

JDK下载地址:

http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html

安装JDK

tar -xvf  /work/source/jdk-8u121-linux-x64.tar.gz -C /work/opt/

mv /work/opt/jdk1.8.0_121/  /work/opt/jdk

 

 

  1. 2   安装并安装tomcat

下载tomcat:

linux命令行中输入以下指令下载apache-tomcat-7.0.63.tar.gz

wget http://apache.fayea.com/tomcat/tomcat-9/v9.0.0.M20/bin/apache-tomcat-9.0.0.M20.tar.gz

安装tomcat

tar -xvf  /work/source/apache-tomcat-9.0.0.M20.tar.gz -C /work/opt/

mv  /work/opt/apache-tomcat-9.0.0.M20 /work/opt/tomcat

解释:tar –xvzf tar.gz包名 –C 目标目录

 

  1. 3   配置环境变量

修改/etc/profile

vi /etc/profile

添加以下内容

设置环境变量,把下面内容追加到 /etc/profile  

##java

export JAVA_HOME=/work/opt/jdk

export  JAVA_BIN=$JAVA_HOME/bin

export  JRE_HOME=${JAVA_HOME}/jre

export  CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar

export  PATH=$JAVA_BIN:$PATH

 

  1. 4   将下载jenkinwar包放在/tomcat/websapp/目录

cp -rf  /work/source/jenkins.war  /work/opt/tomcat/webapps/

 

  1. 5   配置ant

tar -xvf /work/source/apache-ant-1.10.1-bin.t

mv /work/opt/apache-ant-1.10.1 /work/opt/ant

  1. 6   配置maven

tar -xvf /work/source/apache-maven-3.5.0-bin.tar.gz -C /work/opt/

mv /work/opt/apache-maven-3.5.0/ /work/opt/maven

  1. 7   启动tomcat即可访问,默认访问地址:http://xxx.xx.xx.xx:8080/jenkins

出现下面页面

技术分享

这个时候你进入服务器

[email protected]:~#  cat /root/.jenkins/secrets/initialAdminPassword

34c42f4c96fe4af6aae76c56292dd1c9

[email protected]:~#

把这个文件的内容输入到密码框,即可进行下一步

 

下一步出现下面页面,选择 Install suggested plugins 即可

技术分享

 

安装完成之后,需要你创建一个用户,根据自己的要求创建即可,我下面创建的用户是admin,密码:admin

技术分享

 

安装所需插件
有很多插件都是选择的默认的安装的,所以现在需要我们安装的插件不多,Git pluginMaven Integration plugin(这个插件必须安装,如果不安装的话无法创建maven项目,在可选插件中安装这个插件即可),以下是我的插件列表:

技术分享

在可选插件中选择上面的插件安装,如下

技术分享

安装完成如下:

技术分享

 

进行系统配置

此处省略jdk(请注意服务器上需要安装jdk,而不是jre)mavengit的安装

在系统管理中找到Global Tool Configurations,其中包含jdkgitmaven等工具的配置

技术分享

 

技术分享

 

到这来你的jenkins基础环境就部署完成了

技术分享

 

附带 Jenkinsdockerfile

FROM  ubuntusshd

MAINTAINER  gaogd  

RUN  apt-get install wget -y

RUN  mkdir -p /work/opt && mkdir -p   /work/source

COPY apache-ant-1.10.1-bin.tar.gz  /work/source/apache-ant-1.10.1-bin.tar.gz

COPY  apache-tomcat-9.0.0.M20.tar.gz   /work/source/apache-tomcat-9.0.0.M20.tar.gz

COPY  jdk-8u121-linux-x64.tar.gz   /work/source/jdk-8u121-linux-x64.tar.gz

COPY  apache-maven-3.5.0-bin.tar.gz   /work/source/apache-maven-3.5.0-bin.tar.gz

ADD  jenkins.war  /work/source/jenkins.war

ADD  run.sh /run.sh

WORKDIR  /work/source

RUN  tar -xvf /work/source/apache-tomcat-9.0.0.M20.tar.gz -C /work/opt/

RUN mv  /work/opt/apache-tomcat-9.0.0.M20 /work/opt/tomcat

RUN  tar -xvf /work/source/apache-ant-1.10.1-bin.tar.gz -C /work/opt/

RUN mv  /work/opt/apache-ant-1.10.1 /work/opt/ant

RUN  tar -xvf /work/source/jdk-8u121-linux-x64.tar.gz -C /work/opt/

RUN mv  /work/opt/jdk1.8.0_121/ /work/opt/jdk

RUN  tar -xvf /work/source/apache-maven-3.5.0-bin.tar.gz -C /work/opt/

RUN mv  /work/opt/apache-maven-3.5.0/ /work/opt/maven

ENV  JAVA_HOME /work/opt/jdk

ENV  ANT_HOME /work/opt/apache-ant-1.10.1

ENV  CLASSPATH  .:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

ENV  PATH $JAVA_HOME/bin:$ANT_HOME/bin:$PATH

RUN cp  -rf  /work/source/jenkins.war  /work/opt/tomcat/webapps/

#RUN  wget -P /work/opt/tomcat/webapps  http://mirrors.jenkins-ci.org/war/latest/jenkins.war

RUN  apt-get install git  -y

#CMD  /work/opt/tomcat/bin/catalina.sh run

CMD  ["/run.sh"]

EXPOSE  8080

 

##  wget https://www.apache.org/dist/ant/binaries/apache-ant-1.10.1-bin.tar.gz

##  wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war

##  wget  http://apache.fayea.com/tomcat/tomcat-9/v9.0.0.M20/bin/apache-tomcat-9.0.0.M20.tar.gz

##  wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz


##[email protected]:/work/docker/dockerfile/jenkins#  cat run.sh

#!/bin/sh

##/work/opt/tomcat/bin/catalina.sh  start

##/usr/sbin/sshd  -D

 

附带ubuntusshd dockerfile

FROM  ubuntu:14.04

MAINTAINER  gaogd<[email protected]>

RUN rm  -rf /var/lib/apt/lists

RUN cp  /etc/apt/sources.list /etc/apt/sources.list.bak

ADD  sources.list /etc/apt/sources.list

RUN  apt-get clean

RUN  apt-get update

RUN  apt-get install -y  openjdk-7-jdk

RUN  apt-get install -y openssh-server

RUN  apt-get install -y vim tree lrzsz

RUN  echo ‘root:[email protected]‘ |chpasswd

RUN  useradd -m ubuntu -s /bin/bash

RUN  echo "ubuntu:[email protected]" | chpasswd

RUN  echo ‘%ubuntu          ALL=(ALL:ALL)  NOPASSWD: ALL‘ >> /etc/sudoers

ADD  sshd_config /etc/ssh/sshd_config

WORKDIR  /home/ubuntu/

USER  ubuntu

RUN  pwd;ls -a;

RUN  mkdir /home/ubuntu/.ssh

RUN  ssh-keygen -t rsa -P ‘‘ -f /home/ubuntu/.ssh/id_rsa

ADD  authorized_keys /home/ubuntu/.ssh/authorized_keys

USER  root

RUN  chmod 600 /home/ubuntu/.ssh/authorized_keys ;chown -R ubuntu.ubuntu  /home/ubuntu/

RUN mkdir  /var/run/sshd

RUN  sed -ri ‘s/^PermitRootLogin\s+.*/PermitRootLogin yes/‘ /etc/ssh/sshd_config

RUN  sed -ri ‘s/UsePAM yes/#UsePAM yes/g‘ /etc/ssh/sshd_config

CMD  ["/usr/sbin/sshd","-D"]

EXPOSE  4201



[email protected]:/work/docker/dockerfile# cat  ssh/sources.list

# deb  http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse

# deb  http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe  multiverse

# deb  http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe  multiverse

# deb  http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe  multiverse

# deb  http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe  multiverse

#  deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe  multiverse

#  deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted  universe multiverse

#  deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted  universe multiverse

#  deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted  universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/  trusty-backports main restricted universe multiverse


 


本文出自 “奋斗吧” 博客,请务必保留此出处http://lvnian.blog.51cto.com/7155281/1931436

以上是关于jenkins 安装部署的主要内容,如果未能解决你的问题,请参考以下文章

jenkins安装部署实战

Jenkins Server的安装部署方式

Jenkins安装部署

Jenkins部署

jenkins 安装及配置部署操作

Jenkins安装部署