一:背景交代

这两天组长让我这边搭一个持续集成环境。梳理了需求后,因为我们的项目都是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失败---不要随便忽略警告!一个因为文件所有权引发的血案的更多相关文章

  1. Jenkins 配置 FindBugs,Checkstyle,PMD 实现代码的静态检查 (14)

    一.插件介绍 FindBugs:静态分析工具,它检查类或者 JAR 文件,将字节码与一组缺陷模式进行对比以发现可能的问题.利用这个工具,就可以在不实际运行程序的情况对软件进行分析.它可以帮助改进代码的 ...

  2. jenkins+maven配置findbugs+checkstyle+pmd

    一.findbugs+checkstyle+pmd介绍 工具 目的 检查项 FindBugs 检查.class 基于Bug Patterns概念,查找javabytecode(.class文件)中的潜 ...

  3. 干货!Jenkins下配置findbugs、pmd及checkstyle实现代码自动检测

    配置前提: 对于maven项目来说,需要在pom.xml文件的<build><plugins>添加配置</plugins></build> 网上有些地方 ...

  4. Jenkins安装和配置FindBugs、PMD、CheckStyle等插件

    最近研究Jenkins的常用插件的使用,主要使用FindBugs.PMD.CheckStyle.Violations.Emma等插件,主要参考了http://blog.csdn.net/dc_726/ ...

  5. maven项目配置findbugs插件 使用git钩子控制代码的提交

    maven项目配置findbugs插件对代码进行静态检测 当发现代码有bug时,就不让用户commit代码到远程仓库里 没有bug时才可以commit到远程仓库中 (1)新建maven项目 ,配置fi ...

  6. [CentOS]使用Jenkins配置Git+Maven的自动化构建

    背景 最近安装Jenkins,参照网上的各种资料进行尝试,折腾了好久,但是查找了这么多资料,相似度在90%以上!!!,相同的安装过程,测试了几台机器,未曾成功,不得不感慨自己能力有限,最终慢慢摸索,形 ...

  7. Jenkins配置有用摘抄笔记

    使用jenkins配置.net mvc5网站自动构建全过程记录  转自:http://www.cnblogs.com/baiyunchen/p/4724350.html 持续集成是个简单重复劳动,人来 ...

  8. Git+Jenkins配置

    一.新建任务 admin账户登陆jenkins,点击新建按钮-> 选择构建一个自由风格的软件项目,item name 随便输入一个自己认为有意义的名字,点击OK 二.源码管理 源码管理-> ...

  9. 配置FindBugs和常见FindBugs错误

    配置FindBugs: 在这里可以对FindBugs规则等进行详细设置. 选择你的项目,右键 => Properties => FindBugs => 1 Run Automatic ...

随机推荐

  1. Maven 手动添加selenium JAR 包到本地仓库

    安装Maven后我们会在用户目录下发现.m2 文件夹.默认情况下,该文件夹下放置了Maven本地仓库.m2/repository. 在intellij中创建maven项目时,添加 selenium 依 ...

  2. PHP实现发送模板消息到微信公众号

    简述:在这里会具体讲述到如何实现:如何通过后台的代码来实现发送模板消息到已经关注了"心想"公众号的用户. (本人新手,目前实习中,我的所有文档都是在自己开发过程中的记录,有些言语跟 ...

  3. Intel 移位指令的陷阱(转)

    今天发现了一个Intel逻辑左移指令shl的一个bug.   逻辑左移的概念是对给定的目的操作数左移COUNT次,每次移位时最高位移入标志位CF中,最低位补零. 其中OPRD1为目的操作数, 可以是通 ...

  4. Java面试宝典笔记录

    1.一个.java文件中可以有多个类(不是内部类),但是只能有一个public类,且类名和文件同名.(一般不提倡这么写,一类一文件) 2.java保留字:goto, const. 3.访问权限控制 访 ...

  5. 笔记:Maven 聚合和继承

    聚合模块 我们希望一次构建两个或更多项目,而不是到每个模块的目录下分别执行mvn命令,Maven 聚合这一特性就是为该需求服务的, 为了使用聚合,我们必须创建一个聚合模块,通过该模块与其他项目聚合,并 ...

  6. WinSock 异步I/O模型-1

    异步选择(WSAAsyncSelect):异步选择基本定义 异步选择(WSAAsyncSelect)模型是一个有用的异步 I/O 模型.利用这个模型,应用程序可在一个套接字上,接收以 Windows ...

  7. 【Python】 零碎知识积累 I

    大概也是出于初高中时学化学,积累各种反应和物质的习惯,还有大学学各种外语时一看见不认识的词就马上记下来的习惯,形成了一种能记一点是一点的零碎知识记录的癖好.这篇文章就是专门拿来记录这些零碎知识的,没事 ...

  8. 爬虫(BeautifulSoup--select--class的选择)

    <div class="item name" title="中央公园"> <a href="/Attraction_Review-g ...

  9. Linux下导入SQL文件

    导入数据库 一.首先建空数据库 格式: mysql>create database 数据库名;举例: mysql>create database abc; 二.导入数据库 方法一: 选择数 ...

  10. Alpha冲刺No.9

    一.站立式会议 继续解决真实手机中的问题,如果不能解决,请教助教学姐 数据库备忘录的获取和上传 细化界面设计 二.项目实际进展 用一种奇怪的方式解决了真实手机中的问题,在总结里细说. 完成数据库备忘录 ...