"Internet Architecture" Software Architecture - System Architecture electricity supplier (in) -3

docker mounted a nexus, gogs and normal way to install jenkins, before continuing to talk through the integration tomcat, and 3 of those projects together below. Connected sections, do not see this section alone. Source: https://github.com/limingios/netFuture/tree/master/jenkins+nexus+gogs

(A) continue to integrate environmental button

  • 1. Installation jdk and tomcat (192.168.72.104)

Installation jdk1.8

yum install -y wget 

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
#上边的下载比较慢,建议不通过wget的方式,本地下载后上传上去,我下载了3个多小时,当时正好想看电视剧看了几集
tar -zxvf jdk*
cd jdk*
#获取jdk目录填写到下面JAVA_HOME中
pwd
#追加环境变量
echo "export JAVA_HOME=/root/jdk1.8.0_141" >> /etc/profile
echo "export PATH=$""JAVA_HOME/bin:$""PATH" >> /etc/profile
#执行下面这个才能生效
source /etc/profile
java -version
javac -version

Tomcat installation

cd ~
#wget tomcat下载的时候很快
wget https://mirrors.cnnic.cn/apache/tomcat/tomcat-7/v7.0.94/bin/apache-tomcat-7.0.94.tar.gz
tar -zxvf apache-tomcat*
#运行下tomcat看能否启用
cd apache-tomcat*
cd bin
./catalina.sh start

  • maven PW configured 2.jenkins the address (192.168.72.102)

View maven in the virtual machine configuration address Nexus3.x, configured with different nexus2. There are a good source download settings.xml. Ip modifications can be yourself with.

mvn --version

maven installation path of the conf / settings.xml file

cd /opt/soft/maven-3.2.3/conf
vi settings.xml

settings.xml configuration
mirrors add

<mirror>
                <id>nexus</id>
                <mirrorOf>*</mirrorOf>
             <!-- ip 更换成192.168.72.103-->
           <url>http://192.168.72.103:8081/repository/maven-public/</url>
</mirror>

Find <servers> Add Nodes

        <server>
                <id>nexus</id>
                <username>admin</username>
                <password>admin123</password>
        </server>
    

Find the <profiles> node increases

<profile>
        <id>nexus</id>
        <repositories>
                <repository>
                <id>nexus</id>
                <name>Nexus</name>
                <url>http://192.168.72.103:8081/repository/maven-public/</url>
                <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                </snapshots>
                </repository>
        </repositories>
        <pluginRepositories>
        <pluginRepository>
                <id>nexus</id>
                <name>Nexus</name>
                <url>http://192.168.72.103:8081/repository/maven-public/</url>
                <releases>
                        <enabled>true</enabled>
                </releases>
                <snapshots>
                        <enabled>true</enabled>
                </snapshots>
        </pluginRepository>
        </pluginRepositories>
        </profile>

After increasing </ profiles>

<activeProfiles>
          <activeProfile>nexus</activeProfile>
</activeProfiles>

jenkins configuration JDK and Maven
Systems Management - Global Configuration Tool

JDK Configuration

java -version
echo $JAVA_HOME

Maven configuration

mvn -version
echo $MAVEN_HOME

  • maven PW configured 3.nexus the address (192.168.72.103)

In the warehouse, the default will be to find a local plug-in, when there are plug-in is not found, it will go to a third-party warehouse look, quite like with yum on the system! When a local could not find the appropriate plug-in, will be through a proxy (proxy ) to download the plug-type configuration in Central -> Remote Storage.

click to enter

(不建议修改)将其改为阿里云的maven远程仓库:http://maven.aliyun.com/nexus/content/groups/public/
老铁,其实阿里毕竟是镜像库,很多时候在阿里远程仓库中下载不下来,但是maven仓库是可以下载的。不建议修改,如果网络速度特别low的时候,可以先用这个阿里的方式。
https://repo1.maven.org/maven2/

增加第三方库,为的是生成的jar或者war包,可以上传到私服上。起个名字叫:3rd_part 自己定义的,后面上传你的时候需要。

填入名字,Deployment pollcy(Allow redeploy)允许更新,后保存
不设置allow redeploy,会爆400错误。

maven-public

将group中的3rd_part 移动到 Members下

  • 4.jenkins的测试配置,看是否从私服下载,并看看私服的变化

远程git下载的同户名和密码

下拉选择git的设置的用户名和密码

填写Build内容

clean install -Dmaven.test.skip=true -e -U

点击立即构建

点击正在构建的任务

查看控制台输出

nexus3的变化

jenkins的构建信息

构建结果

在192.168.72.102机器上,使用命令进行上传

# Dfile路径就是jenkins打包后的成功路径
 mvn deploy:deploy-file -DgroupId=com.test -DartifactId=example -Dversion=1.0.0 -Dpackaging=jar -Dfile=/root/.jenkins/workspace/abc-test/target/guns.jar -Durl=http://192.168.72.103:8081/repository/3rd_part/ -DrepositoryId=nexus

新建立的3rd_part仓库里已经上传成功

  • 5.jenkins(192.168.72.102)加上上面的命令

任务中增加编译后的shell脚本

 mvn deploy:deploy-file -DgroupId=com.test -DartifactId=example -Dversion=1.0.0 -Dpackaging=jar -Dfile=/root/.jenkins/workspace/abc-test/target/guns.jar -Durl=http://192.168.72.103:8081/repository/3rd_part/ -DrepositoryId=nexus

立即构建,查看输出末尾有uploaded操作。

PS:基本的流程已经构建完成了。jenkins已经跟私服连接上了。下一步就从tomcat关联上jenkins构建后的war包或者jar包。

几个重点需要注意点
0.这里使用的是nexus3,跟nexus2还是有区别的。特别是私服的settings.xml设置这块。
1.settings的设置【参考源码中的settings.xml文件】
2.nexus新建仓库允许更新操作
3.上传项目打包后的war或者jar包的时候,命令
4.构建的时候的命令建议先clean 然后install,跳过test。



作者:IT人故事会
链接:https://www.jianshu.com/p/a6bfd1841890
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

Guess you like

Origin blog.csdn.net/qq_28505809/article/details/95317691