1、拉取代码或编译慢

  • 网速慢
  • jenkins服务器内存或cpu配置低或不足
  • 程序本身比较大

2、发包慢

  • 网速慢

特殊情况:
两台服务器不在同一个网段,编译传包都特别慢
解决办法:在目标服务器上面装一个maven、git,直接在目标服务器编译打包

maven下载地址
maven安装

[root@ecs-3824-0001 jenkins]# tar -xf apache-maven-3.5.2-bin.tar.gz 
[root@ecs-3824-0001 jenkins]# ls
apache-maven-3.5.2  apache-maven-3.5.2-bin.tar.gz
[root@ecs-3824-0001 jenkins]# vim /etc/profile
    export MAVEN_HOME=/data/jenkins/apache-maven-3.5.2
    export PATH=$PATH:$MAVEN_HOME/bin
    
[root@ecs-3824-0001 jenkins]# source /etc/profile
[root@ecs-3824-0001 jenkins]# mvn -v
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T15:58:13+08:00)
Maven home: /data/jenkins/apache-maven-3.5.2
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /opt/jdk1.8.0_144/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.15.2.el7.x86_64", arch: "amd64", family: "unix"

[root@ecs-3824-0001 apache-maven-3.5.2]# cd conf/
[root@ecs-3824-0001 conf]# ls
logging  settings.bak  settings.xml  toolchains.xml
编辑这个文件settings.xml,里面配置了公司私库的地址

git安装

[root@ecs-3824-0001 jenkins]# yum -y install git
[root@ecs-3824-0001 jenkins]# git --version
git version 1.8.3.1

jenkins新建节点
在这里插入图片描述

在这里插入图片描述
保存之后用页面给的命令去目标主机运行命令:
自己包下载下来,双击页面的agent.jar就下载了

[root@ecs-3824-0001 jenkins]# ps -aux|grep agent.jar 
root       940  0.1  0.8 7402500 133964 ?      Sl   Feb09   2:03 /CloudResetPwdUpdateAgent/depend/jre/bin/java -Dorg.tanukisoftware.wrapper.WrapperSimpleApp.maxStartMainWait=40 -Djava.library.path=../lib -classpath ../lib/resetpwdupdateagent.jar:../lib/wrapper.jar:../lib/json-20160810.jar:../lib/log4j-api-2.8.2.jar:../lib/log4j-core-2.8.2.jar -Dwrapper.key=KBaMZa1Db8i9uZa2 -Dwrapper.backend=pipe -Dwrapper.disable_console_input=TRUE -Dwrapper.pid=737 -Dwrapper.version=3.5.26 -Dwrapper.native_library=wrapper -Dwrapper.arch=x86 -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=180 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp CloudResetPwdUpdateAgent
root      1261  4.3  5.3 9032220 873024 pts/0  Sl   16:55   2:24 java -jar agent.jar -jnlpUrl http://121.36.91.192:9000/jenkins/computer/%E4%B9%8C%E5%85%B0%E5%AF%9F%E5%B8%83/jenkins-agent.jnlp -secret 2e83898175aef1e7ee743086f2872dbb6685059039b63425c92cdb9c8dc727b3 -workDir /data/jenkins
root      6989 38.2  6.5 8817420 1070652 pts/0 Sl   17:48   1:04 /opt/jdk1.8.0_144/bin/java -cp /data/jenkins/maven35-agent.jar:/data/jenkins/apache-maven-3.5.2/boot/plexus-classworlds-2.5.2.jar:/data/jenkins/apache-maven-3.5.2/conf/logging jenkins.maven3.agent.Maven35Main /data/jenkins/apache-maven-3.5.2 /data/jenkins/agent.jar /data/jenkins/maven35-interceptor.jar /data/jenkins/maven3-interceptor-commons.jar 41054

指定构建节点
在这里插入图片描述

jenkins构建报错,代理没权限访问秘钥文件,直接改成用密码登陆就好了

SSH: Connecting from host [ecs-3824-0001]
SSH: Connecting with configuration [121.37.88.111] ...
ERROR: Exception when publishing, exception message [Failed to read file - filename [/home/dev/.ssh/id_rsa] (relative to JENKINS_HOME if not absolute). Message: [java.lang.SecurityException: agent may not read /home/dev/.ssh/id_rsa
See https://jenkins.io/redirect/security-144 for more details]]
Build step 'Send build artifacts over SSH' changed build result to UNSTABLE
Finished: UNSTABLE

在这里插入图片描述
我这里填的是目标服务器的内网IP,因为不在一个网段所以不成功,这里不用管它,直接保存
原因:你指定了运行节点,在构建过程中实际是目标服务器在运行,这台服务器和上面我写的那个内网IP是通的,所以是可以构建成功的

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐