1、tomcat不要使用8.5.13,部署时会出问题,我使用的tomcat版本是8.5.31
2、tomcat需要修改conf/context.xml文件,在Context元素下增加antiResourceLocking=”true”,修改完的效果如下
<Context antiResourceLocking="true">
否则在jenkins自动部署时会报出Unable to delete [D:\tomcat\webapps\testproj]的错误
3、配置nginx的时候不能把jenkins在location中指定为二级目录,否则会报404,比如:
location /jenkins/ {
proxy_pass http://127.0.0.1:8888/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
可能是我刚接触不熟悉,希望有大牛能指点一二
3、配置nginx时,我使用的是https,但是在request.getgetScheme()时取到的始终是http,这时需要分别修改nginx和tomcat的配置文件,不用修改代码
第一、nginx的location中的配置,多增加一个参数,如下
proxy_set_header X-Forwarded-Proto $scheme;
第二、修改tomcat的conf/server.xml文件,在Engine元素下增加一个Value,如下
<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto"
protocolHeaderHttpsValue="https"/>
注意:是在Engine下
修改完以上2处,request.getScheme()方法就会正常返回了
4、由于我的项目使用的是springmvc+spring+hibernate,所以一开始使用maven打包时没有把数据库表映射文件,也就是*.hbm.xml文件一同打包,导致发布后所有数据库查询语句全报错。(刚接触不熟,呵呵),需要在pom.xml文件中的build元素下增加resource,把*.hbm.xml一起打包,需要把resources文件夹下的资源一同打包,如下
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.hbm.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
5、在jenkins下配置git的账户信息时,犯了一个小白问题,我的gitlab使用的是ssh方式,密钥之前生成过了,在jeknins的credentials下增加时,选的是直接输入方式,应该复制id_rsa里的内容,一开始复制的是id_rsa.pub的内容,导致在构建配置时返回returned status code 128的错误。切记是不带.pub的那个
目前就这么多,有问题再追加