jenkins配置findbugs失败---不要随便忽略警告!一个因为文件所有权引发的血案
一:背景交代
这两天组长让我这边搭一个持续集成环境。梳理了需求后,因为我们的项目都是maven项目,所以我选择了jenkins+外置maven(区别于直接从jenkins里面安装)的方案。(centos 7)
jenkins的安装先不细说,maven的安装也是直接参考了https://maven.apache.org/install.html。
maven信息:
[root@pas upload]# mvn -v
Apache Maven 3.5. (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; --25T03::+:)
Maven home: /usr/local/apache-maven-3.5.3
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: /usr/local/jdk1..0_161/jre
Default locale: zh_CN, platform encoding: UTF-
OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
接下来,说下我的maven的配置。
我修改了maven安装目录下的conf下的settings.xml(/usr/local/apache-maven-3.5.3/conf/settings.xml)
1.修改仓库位置
<localRepository>/home/upload/Repo_backup</localRepository>
由于我的windows服务器上已经有了本地仓库,所以直接压缩成zip后上传到了centos上,解压到了 /home/upload/Repo_backup。
2.增加私服相关配置
<?xml version="1.0" encoding="UTF-8"?> <!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--> <!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| users on a machine (assuming they're all using the same Maven
| installation). It's normally provided in
| ${maven.conf}/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -gs /path/to/global/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>/home/upload/Repo_backup</localRepository> <!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
--> <!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
--> <!-- pluginGroups
| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups> <!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies> <!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers> <server>
<id>bol-release</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>bol-snapshot</id>
<username>admin</username>
<password>admin123</password>
</server>
<!-- server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
--> <!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers> <!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors> <mirror>
<id>bolRemote</id>
<mirrorOf>*</mirrorOf>
<name>cts</name>
<url>http://192.168.19.210:8081/nexus/content/groups/public/</url>
</mirror>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors> <!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a system property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
3.jenkins安装maven插件并新建maven项目
系统管理--》管理插件--》可选插件--》Maven Integration plugin
勾选后点直接安装,等待安装完成后,新建任务中就会出现下图所示的“构建一个maven项目”的选项:
4.项目配置
配置svn
配置maven goal:
然后点保存,启动立即构建后,works well。
二:问题出现
我准备给这个项目加上findbugs来进行代码分析检查。
步骤很简单,我只是在build中增加了findbugs:findbugs:
ok。以上配置完成,开始构建。
然而构建总是报错,提示如下:
[ERROR] Failed to execute goal org.codehaus.mojo:findbugs-maven-plugin:3.0.5:findbugs (default-cli) on project my-app: Execution default-cli of goal org.codehaus.mojo:findbugs-maven-plugin:3.0.5:findbugs failed: Plugin org.codehaus.mojo:findbugs-maven-plugin:3.0.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.codehaus.mojo:findbugs-maven-plugin:jar:3.0.5 -> org.apache.maven.reporting:maven-reporting-impl:jar:3.0.0 -> org.apache.maven.doxia:doxia-core:jar:1.7 -> xmlunit:xmlunit:jar:1.5: Failed to read artifact descriptor for xmlunit:xmlunit:jar:1.5: Could not transfer artifact xmlunit:xmlunit:pom:1.5 from/to central (https://repo.maven.apache.org/maven2): /home/upload/Repo_backup/xmlunit/xmlunit/1.5/xmlunit-1.5.pom.part.lock (没有那个文件或目录) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException排除过程:
1.我感觉是因为私服有问题,可能私服中不存在该版本的findbugs插件的依赖,导致下载失败。 首先尝试了将maven的settings.xml中的私服配置去掉,然后重新构建,依然有问题。后来发现项目的pom中配置了私服,因此换了个项目(该项目的pom中没有用到私服中的包),重新构建。 2.问题依旧。这次依旧没有了私服,难道是maven中央仓库的问题,仔细去找了maven库,依赖都存在啊。
3.难道是下载不下来么? 尝试了去本地库中将findbugs-maven-plugin目录删除掉,希望能重新下载下来,构建却依然报错。
3.既然下载有问题,于是又从windows开发机器上将findbugs-maven-plugin拷贝到centos上后,重新构建,依然报错。 后来(很后很后,昨天一下午都没搞定,所以是后到了今天上午)发现:
编译过程中有些警告:
我就想:为啥会创建这些东西失败呢?感觉没道理啊。
没有权限吗?但如下图所示,我早就将该目录下的文件所有者改成了jenkins。
那?难道是?
注意上图,刚开始的时候,我是从windows上上传了Repo_backup.zip,然后解压缩到Repo_backup。因为是root用户操作的,所以
理所当然,Repo_backup的用户和用户组是root
而这会导致jenkins在执行时,所用的jenkins用户根本无法写入Repo_backup目录。所以才有了诸多的创建失败。 创建失败,为啥没报错呢?因为那些jar包,在我本地的windows上是有的,但是jenkins重新去maven中央仓库更新时,看到本地仓库有了,但是应该还是会更新下.lastUpdated之类的文件
来刷新时间戳吧(我猜的)。 总之,当我将Repo_backup的用户和组修改为jenkins后,findbugs终于正常了。
三:结语
所以,其实最后呢,还是因为自己的马虎大意或者说对linux还是不够懂,也可以说:已经习惯性地忽略警告信息导致了这次的大坑。
以后,大概不会再随便忽略warning信息了
jenkins配置findbugs失败---不要随便忽略警告!一个因为文件所有权引发的血案的更多相关文章
- Jenkins 配置 FindBugs,Checkstyle,PMD 实现代码的静态检查 (14)
一.插件介绍 FindBugs:静态分析工具,它检查类或者 JAR 文件,将字节码与一组缺陷模式进行对比以发现可能的问题.利用这个工具,就可以在不实际运行程序的情况对软件进行分析.它可以帮助改进代码的 ...
- jenkins+maven配置findbugs+checkstyle+pmd
一.findbugs+checkstyle+pmd介绍 工具 目的 检查项 FindBugs 检查.class 基于Bug Patterns概念,查找javabytecode(.class文件)中的潜 ...
- 干货!Jenkins下配置findbugs、pmd及checkstyle实现代码自动检测
配置前提: 对于maven项目来说,需要在pom.xml文件的<build><plugins>添加配置</plugins></build> 网上有些地方 ...
- Jenkins安装和配置FindBugs、PMD、CheckStyle等插件
最近研究Jenkins的常用插件的使用,主要使用FindBugs.PMD.CheckStyle.Violations.Emma等插件,主要参考了http://blog.csdn.net/dc_726/ ...
- maven项目配置findbugs插件 使用git钩子控制代码的提交
maven项目配置findbugs插件对代码进行静态检测 当发现代码有bug时,就不让用户commit代码到远程仓库里 没有bug时才可以commit到远程仓库中 (1)新建maven项目 ,配置fi ...
- [CentOS]使用Jenkins配置Git+Maven的自动化构建
背景 最近安装Jenkins,参照网上的各种资料进行尝试,折腾了好久,但是查找了这么多资料,相似度在90%以上!!!,相同的安装过程,测试了几台机器,未曾成功,不得不感慨自己能力有限,最终慢慢摸索,形 ...
- Jenkins配置有用摘抄笔记
使用jenkins配置.net mvc5网站自动构建全过程记录 转自:http://www.cnblogs.com/baiyunchen/p/4724350.html 持续集成是个简单重复劳动,人来 ...
- Git+Jenkins配置
一.新建任务 admin账户登陆jenkins,点击新建按钮-> 选择构建一个自由风格的软件项目,item name 随便输入一个自己认为有意义的名字,点击OK 二.源码管理 源码管理-> ...
- 配置FindBugs和常见FindBugs错误
配置FindBugs: 在这里可以对FindBugs规则等进行详细设置. 选择你的项目,右键 => Properties => FindBugs => 1 Run Automatic ...
随机推荐
- mui实现切换选项卡
mui切换选项卡头目对应选项内容是webAPP应用最多的功能 引入mui文件: 引入mui-segmented-control类实现顶部头目: 引入mui-content-padded类加入各选项卡内 ...
- android 获取wifi列表,如果你忽略了这个细节,可能你的软件会崩溃
一:业务描述 最近公司有一个小需求,用户点击wifi扫描按钮(注意:是用户主动点击wifi扫描按钮),app去扫描附近的wifi,显示在listView中,仅此而已,app都不用去连接某个wifi,看 ...
- Linux(CentOS 7)环境下安装MySQL
在CentOS中默认安装有MariaDB,但是我们需要的是MySQL,安装MySQL可以覆盖MariaDB MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 ...
- Iview的开发之路
采用了Vue-cli的方式. 1.反向代理 devServer: { host: '127.0.0.1', port: 9000, proxy: { '/gonghui/': { target: 'h ...
- Acer Aspire E1 471G 加装SSD+机械盘后无法启动的问题
老笔记本 Acer Aspire E1 471G 加装了一块 SSD 作为系统盘(win10),原机械盘格式化后,装在光驱托架上作为数据盘. 可能会出现: 系统无法启动,显示找不到启动设备,并且在F2 ...
- SpringBoot集成redis的key,value序列化的相关问题
使用的是maven工程 springBoot集成redis默认使用的是注解,在官方文档中只需要2步; 1.在pom文件中引入即可 <dependency> <groupId>o ...
- js前端读写文件的方法(json、excel)
1.前端读取文件的实现 关键:利用文件上传对话框预览本地文件.利用FileReader读取文件 前端预览本地文件 <input tabindex="-1" id=" ...
- 简单爬虫 -- 以爬取NASA AOD数据(TIFF文件)为例
目录: 网站分析 爬取下载链接 爬取TIFF图片 1.网站分析 主页面:https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MYDAL2_M_AER_OD ...
- 测试驱动开发实践2————从testList开始
内容指引 1.测试之前 2.改造dto层代码 3.改造dao层代码 4.改造service.impl层的list方法 5.通过testList驱动domain领域类的修改 一.测试之前 在" ...
- python 面向对象的程序设计
一:什么是编程范式? 编程是程序员用特定的语法 + 数据结构 + 算法组成的代码来告诉计算机如何执行任务的过程. 如果把编程的过程比喻为练习武功,那么编程范式指的就是武林中的各种流派,而在编程的世界里 ...