安装部署Jenkins服务

安装JDK和Maven

将需要安装的JDK安装包上传到Linux系统指定的文件夹下,并且命令进入该文件夹下。图片[1]-安装部署Jenkins服务-剧毒之触博客

tar -zxvf jdk-8u144-linux-x64.tar.gz

解压完成后,添加环境变量

vim /etc/profile
export JAVA_HOME=路径
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

图片[2]-安装部署Jenkins服务-剧毒之触博客

source /etc/profile

输入java,完成安装

图片[3]-安装部署Jenkins服务-剧毒之触博客

tar -zxvf apache-maven-3.8.5-bin.tar.gz -C /usr/local/

安装Tomcat部署Jenkins

解压tomcat包

tar -zxvf apache-tomcat-7.0.56.tar.gz

图片[4]-安装部署Jenkins服务-剧毒之触博客

将Jenkins.war移动到webapps文件夹,并启动bin下的启动脚本

自己移动一下!

图片[5]-安装部署Jenkins服务-剧毒之触博客

更改Tomcat编码

vim /opt/apache-tomcat-7.0.56/conf/server.xml
URIEncoding="UTF-8"

图片[6]-安装部署Jenkins服务-剧毒之触博客

配置Tomcat用户名和密码

vim /opt/apache-tomcat-7.0.56/conf/tomcat-users.xml
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <user username="chaiquan" password="chaiquan" roles="manager-gui,manager-script,manager-jmx,manager-status"/>

图片[7]-安装部署Jenkins服务-剧毒之触博客

运行脚本

cd /opt/apache-tomcat-7.0.56/bin
./startup.sh

图片[8]-安装部署Jenkins服务-剧毒之触博客

图片[9]-安装部署Jenkins服务-剧毒之触博客

浏览器输入IP:8080/jenkins访问Jenkins

IP:8080/jenkins

图片[10]-安装部署Jenkins服务-剧毒之触博客

出现这个页面我们根据提示即可

cat /root/.jenkins/secrets/initialAdminPassword

图片[11]-安装部署Jenkins服务-剧毒之触博客

输入后跳转安装插件页面,选择推荐安装。此过程可能会很久,请耐心等待!

在设置Jenkins的url时直接点击下一步!然后自己新建个管理员用户!

图片[12]-安装部署Jenkins服务-剧毒之触博客
图片[13]-安装部署Jenkins服务-剧毒之触博客
图片[14]-安装部署Jenkins服务-剧毒之触博客

然后,我们前往安装需要的插件!

Manage Jenkins–> Manage Plugins –> Available

搜索:Localization: Chinese (Simplified)、Maven Integration、Deploy to container、Git client、GIT server 和 Git

图片[15]-安装部署Jenkins服务-剧毒之触博客
图片[16]-安装部署Jenkins服务-剧毒之触博客
图片[17]-安装部署Jenkins服务-剧毒之触博客
图片[18]-安装部署Jenkins服务-剧毒之触博客

JDK和Maven 配置

JDK

点击 Manage Jenkins –> Global Tool Configuration –> JDK

图片[19]-安装部署Jenkins服务-剧毒之触博客
图片[20]-安装部署Jenkins服务-剧毒之触博客

图片[21]-安装部署Jenkins服务-剧毒之触博客

图片[22]-安装部署Jenkins服务-剧毒之触博客

Maven

点击 Manage Jenkins –> Global Tool Configuration –> Maven

图片[23]-安装部署Jenkins服务-剧毒之触博客
图片[24]-安装部署Jenkins服务-剧毒之触博客

创建项目

进入主页创建一个名为qcloud

图片[25]-安装部署Jenkins服务-剧毒之触博客
图片[26]-安装部署Jenkins服务-剧毒之触博客

在接下来的页面中,找到git 选择它,在Repository URL选框里填写自己在Gogs新建的仓库

图片[27]-安装部署Jenkins服务-剧毒之触博客

图片[28]-安装部署Jenkins服务-剧毒之触博客

之后点击应用!

然后选择结构触发器

勾选Build whenever a SNAPSHOT dependency is builtPoll SCM并在日程表填写以下日程:

H/1 * * * *

然后点击应用!

然后选择构建环境

在Build中,找到Root POMGoals and options

在里面分别填写:

course-maven/pom.xml
clean install

图片[29]-安装部署Jenkins服务-剧毒之触博客

点击保存!

配置Maven本地仓库

vim /usr/local/apache-maven-3.5.0/conf/settings.xml

以下配置文件必须在 <settings></settings>中配置,否则无法构建!

<localRepository>/opt/maven-repository</localRepository>

图片[30]-安装部署Jenkins服务-剧毒之触博客

保存退出,在opt下新建文件夹maven-repository,然后将包文件上传,后续提供文件下载

图片[31]-安装部署Jenkins服务-剧毒之触博客

最后进入项目所在文件

图片[32]-安装部署Jenkins服务-剧毒之触博客

cd /root/xiandian-master

依次输入以下命令

git init
git add course-maven
git config --global user.email "admin@thtown.cn"
git config --global user.name "chaiquan"
git commit -am "add course -maven"

然后准备上传到仓库

git remote add origin 仓库地址
git remote add origin http://192.168.145.100:90/chaiquan/chaiquan_goujian.git
git push -u origin master

图片[33]-安装部署Jenkins服务-剧毒之触博客

图片[34]-安装部署Jenkins服务-剧毒之触博客

推送成功!

替换course-maven/pom.xml为:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <groupId>com.xd.cloud</groupId>
        <artifactId>course</artifactId>
        <packaging>war</packaging>
        <version>1.0</version>

        <properties>
            <org.springframework-version>4.0.0.RELEASE</org.springframework-version>
            <org.hibernate-version>4.3.1.Final</org.hibernate-version>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <shiro.version>1.2.3</shiro.version>
        </properties>

        <dependencies>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5.2</version>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>4.4.4</version>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>4.5.1</version>
            </dependency>

            <dependency>
                <groupId>ant</groupId>
                <artifactId>ant</artifactId>
                <version>1.6.5</version>
            </dependency>

            <!-- servlet -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
            </dependency>
            <!-- freemarker -->
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
                <version>2.3.20</version>
            </dependency>
            <dependency>
                <groupId>com.jagregory.shiro</groupId>
                <artifactId>shiro-freemarker-tags</artifactId>
                <version>0.1</version>
            </dependency>

            <!-- Jackson -->
            <dependency>
                <groupId>org.codehaus.jackson</groupId>
                <artifactId>jackson-mapper-asl</artifactId>
                <version>1.9.13</version>
            </dependency>

            <!--utils -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>15.0-rc1</version>
            </dependency>

            <!-- Apache Commons -->
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.6</version>
            </dependency>
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>3.2.1</version>
            </dependency>
            <dependency>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils</artifactId>
                <version>1.8.3</version>
            </dependency>
            <dependency>
                <groupId>commons-dbutils</groupId>
                <artifactId>commons-dbutils</artifactId>
                <version>1.5</version>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.3</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.8</version>
            </dependency>
            <dependency>
                <groupId>commons-configuration</groupId>
                <artifactId>commons-configuration</artifactId>
                <version>1.10</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.4</version>
            </dependency>

            <dependency>
                <groupId>commons-pool</groupId>
                <artifactId>commons-pool</artifactId>
                <version>1.5.6</version>
            </dependency>

            <dependency>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
                <version>1.4.4</version>
            </dependency>

            <!-- slf4j -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.21</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.7.21</version>
            </dependency>

            <!-- mysql driver -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.15</version>
            </dependency>

            <!-- c3p0 datasource -->
            <dependency>
                <groupId>c3p0</groupId>
                <artifactId>c3p0</artifactId>
                <version>0.9.1.2</version>
            </dependency>

            <!-- JUnit -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.11</version>
                <scope>provided</scope>
            </dependency>

            <!-- spring 4 -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${org.springframework-version}</version>
                <exclusions>
                    <!-- Exclude Commons Logging in favor of SLF4j -->
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <!--<dependency> -->
            <!--<groupId>org.springframework</groupId> -->
            <!--<artifactId>spring-aspects</artifactId> -->
            <!--<version>${org.springframework-version}</version> -->
            <!--</dependency> -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <!--<dependency> -->
            <!--<groupId>org.springframework</groupId> -->
            <!--<artifactId>spring-jdbc</artifactId> -->
            <!--<version>${org.springframework-version}</version> -->
            <!--</dependency> -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${org.springframework-version}</version>
            </dependency>
            <!--<dependency> -->
            <!--<groupId>org.springframework</groupId> -->
            <!--<artifactId>spring-jms</artifactId> -->
            <!--<version>${org.springframework-version}</version> -->
            <!--</dependency> -->
            <!--<dependency> -->
            <!--<groupId>org.springframework</groupId> -->
            <!--<artifactId>spring-test</artifactId> -->
            <!--<version>${org.springframework-version}</version> -->
            <!--<scope>test</scope> -->
            <!--</dependency> -->

            <!-- AspectJ -->
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjrt</artifactId>
                <version>1.7.4</version>
            </dependency>

            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>1.7.4</version>
            </dependency>

            <!-- hiberante 4 -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>${org.hibernate-version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>${org.hibernate-version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>${org.hibernate-version}</version>
            </dependency>
            <dependency>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
                <version>1.0.0.GA</version>
                <scope>provided</scope>
            </dependency>

            <!--enable hibernate to use its proxy model -->
            <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.18.1-GA</version>
            </dependency>
            <!--sitemesh -->
            <dependency>
                <groupId>opensymphony</groupId>
                <artifactId>sitemesh</artifactId>
                <version>2.4.2</version>
            </dependency>

            <!--<dependency> -->
            <!--<groupId>org.jboss.logging</groupId> -->
            <!--<artifactId>jboss-logging</artifactId> -->
            <!--<version>3.1.0.CR2</version> -->
            <!--</dependency> -->

            <!-- apache shiro -->
            <dependency>
                <groupId>org.apache.shiro</groupId>
                <artifactId>shiro-core</artifactId>
                <version>${shiro.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.shiro</groupId>
                <artifactId>shiro-web</artifactId>
                <version>${shiro.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.shiro</groupId>
                <artifactId>shiro-ehcache</artifactId>
                <version>${shiro.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.shiro</groupId>
                <artifactId>shiro-spring</artifactId>
                <version>${shiro.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.shiro</groupId>
                <artifactId>shiro-cas</artifactId>
                <version>${shiro.version}</version>
            </dependency>

            <!--百度编辑器 -->
            <dependency>
                <groupId>com.baidu.ueditor</groupId>
                <artifactId>ueditor</artifactId>
                <version>1.1.1</version>
            </dependency>

            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>2.8.5</version>
            </dependency>

            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>1.0</version>
            </dependency>

            <dependency>
                <groupId>net.sf.json-lib</groupId>
                <artifactId>json-lib</artifactId>
                <version>2.4</version>
                <classifier>jdk15</classifier>
            </dependency>

            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.10-FINAL</version>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>3.10-FINAL</version>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-scratchpad</artifactId>
                <version>3.10-FINAL</version>
            </dependency>
            <dependency>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
                <version>2.0.2</version>
            </dependency>
            <dependency>
                <groupId>org.apache.xmlbeans</groupId>
                <artifactId>xmlbeans</artifactId>
                <version>2.6.0</version>
            </dependency>
            <dependency>
                <groupId>stax</groupId>
                <artifactId>stax-api</artifactId>
                <version>1.0.1</version>
            </dependency>
            <!-- memcached -->
            <dependency>
                <groupId>com.danga</groupId>
                <artifactId>memcached</artifactId>
                <version>2.6.6</version>
            </dependency>
            <!-- 腾讯云API -->
            <!-- https://mvnrepository.com/artifact/com.qcloud/cos_api -->
            <dependency>
                <groupId>com.qcloud</groupId>
                <artifactId>cos_api</artifactId>
                <version>4.4</version>
            </dependency>

            <dependency>
                <groupId>com.qcloud</groupId>
                <artifactId>qcloud-vod</artifactId>
                <version>1.0.0</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/com.jacob/jacob -->
            <dependency>
                <groupId>com.jacob</groupId>
                <artifactId>jacob</artifactId>
                <version>1.10</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/org.pacesys/openstack4j -->
            <dependency>
                <groupId>org.pacesys</groupId>
                <artifactId>openstack4j</artifactId>
                <version>3.0.3</version>
                <classifier>withdeps</classifier>
            </dependency>

        </dependencies>

        <build>
            <finalName>ROOT</finalName>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>9.3.0.M2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <!-- 配置jre/lib/rt.jar ,jre7+被删除 -->
                <!-- <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> 
                    <configuration> <source>1.6</source> <target>1.6</target> <encoding>UTF-8</encoding> 
                    <optimize>true</optimize> <debug>true</debug> <showDeprecation>true</showDeprecation> 
                    <showWarnings>false</showWarnings> <compilerArguments> <verbose /> <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath> 
                    </compilerArguments> </configuration> </plugin> -->
            </plugins>
        </build>
    </project>

进入chaiquan_xyh/src/master/course-maven/src/main/resources/jdbc.properties编写数据库

注意 请填写安装gogs时的数据库和密码,然后点击下面的提交变更

图片[35]-安装部署Jenkins服务-剧毒之触博客

返回Jenkins进入qcloud项目,点击构建。

正在构建:

图片[36]-安装部署Jenkins服务-剧毒之触博客

构建的过程应该会很漫长,耐心等待~~

图片[37]-安装部署Jenkins服务-剧毒之触博客

图片[38]-安装部署Jenkins服务-剧毒之触博客

成功!

使用war包

cd /root/.jenkins/workspace/qcloud/course-maven/target

图片[39]-安装部署Jenkins服务-剧毒之触博客

然后我使用Docker进行部署验证ROOT.war,可以正常使用。

图片[40]-安装部署Jenkins服务-剧毒之触博客

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论