Jenkins+sonar7.3集成
Jenkins安装请参考:https://blog.csdn.net/CheNorton/article/details/50327825?utm_source=copy
Jenkins更新请参考:https://blog.csdn.net/u013201439/article/details/72984652
sonar7.3安装
整体的步骤是:
- 安装JDK支持
- 安装mySQL数据库
- 安装SonarQube
安装包: https://pan.baidu.com/s/11pq11J3NhyciOsuF5gGLdw 提取码:z9qu
上传安装包到 /tools/
一:安装JDK
rpm -ivh jdk-8u11-linux-x64.rpm
[root@jason tools]# whereis java
java: /usr/bin/java /usr/share/java
将java配置加入环境变量
[root@jason tools]# cat /etc/profile |grep -Ev '^$|^#'
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
export PATH
export JAVA_HOME=/usr/bin/java
export SONAR_HOME=/tools/sonarqube-7.3/bin/linux-x86-64/
export SONAR_RUNNER_HOME=/tools/sonar-scanner-2.8/bin/
export PATH=$JAVA_HOME/bin:$SONAR_HOME:$SONAR_RUNNER_HOME:$PATH
export CLASSPATH=./$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
生效
source /etc/profile
二:安装mysql并创建sonar服务器数据库
安装数据库不赘述,创建sonar服务器数据库
mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE USER 'sonar' IDENTIFIED BY 'jason_zhang';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'jason_zhang';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'jason_zhang';
mysql> FLUSH PRIVILEGES;
三:安装sonar7.3
[root@jason tools]# unzip sonarqube-7.3
[root@jason tools]# unzip sonar-scanner-2.8
[root@jason tools]# chmod -R 777 /tools/
[root@jason tools]# vim sonarqube-7.3/conf/sonar.properties
[root@jason conf]# cat sonar.properties |grep -Ev '^$|^#'
sonar.jdbc.username=sonar
sonar.jdbc.password=jason_zhang
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerforman
ce&useSSL=false
sonar.web.host=0.0.0.0
sonar.web.port=9000
由于sonar
是不允许root用户情况下运行的,因此需要先创建一个非root用户。
这里,创建一个名为sonar
的用户,密码为jason_zhang
useradd sonar
passwd sonar
配置sonar用户环境变量
[sonar@jason linux-x86-]$ cd /home/sonar/
[sonar@jason ~]$ cat .bash_profile |grep -Ev '^$|^#'
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export JAVA_HOME=/usr/bin/java
export SONAR_HOME=/tools/sonarqube-7.3/bin/linux-x86-/
export SONAR_RUNNER_HOME=/tools/sonar-scanner-2.8/bin/
export PATH=$JAVA_HOME/bin:$SONAR_HOME:$SONAR_RUNNER_HOME:$PATH
export CLASSPATH=./$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
切换到sonar用户并启动sonar服务
[root@jason bin]# su sonar
[sonar@jason bin]$ cd /tools/sonarqube-7.3/bin/linux-x86-/
[sonar@jason linux-x86-]$ ./sonar.sh start
Starting SonarQube...
Started SonarQube.
查看sonar.log及es.log查看服务是否正常启动
[root@jason ~]# tail -30f /tools/sonarqube-7.3/logs/sonar.log
2018.10. :: INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='ce', ipcIndex=, logFilenamePrefix=ce]] from [/tools/sonarq
ube-7.3]: /usr/java/jdk1..0_11/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF- -Djava.io.tmpdir=/tools/sonarqube-7.3/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:/tools/sonarqube-7.3/lib/jdbc/mysql/mysql-connector-java-5.1.46.jar org.sonar.ce.app.CeServer /tools/sonarqube-7.3/temp/sq-process7242945522727736634properties2018.10.15 16:38:57 INFO app[][o.s.a.SchedulerImpl] Process[ce] is up
2018.10.15 16:38:57 INFO app[][o.s.a.SchedulerImpl] SonarQube is up
TERM trapped. Shutting down.
2018.10.15 18:18:43 INFO app[][o.s.a.SchedulerImpl] Stopping SonarQube
2018.10.15 18:18:44 WARN app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 143
2018.10.15 18:18:44 INFO app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.10.15 18:18:46 WARN app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [ce]: 143
2018.10.15 18:18:46 INFO app[][o.s.a.SchedulerImpl] Process [ce] is stopped
2018.10.15 18:18:46 WARN app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [web]: 143
2018.10.15 18:18:46 INFO app[][o.s.a.SchedulerImpl] Process [web] is stopped
2018.10.15 18:18:46 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2018.10.16 11:19:50 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /tools/sonarqube-7.3/temp
2018.10.16 11:19:50 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.10.16 11:19:50 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/tools/sonarq
ube-7.3/elasticsearch]: /tools/sonarqube-7.3/elasticsearch/bin/elasticsearch -Epath.conf=/tools/sonarqube-7.3/temp/conf/es2018.10.16 11:19:50 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2018.10.16 11:19:51 INFO app[][o.e.p.PluginsService] no modules loaded
2018.10.16 11:19:51 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2018.10.16 11:20:07 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
2018.10.16 11:20:07 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/tools/sona
rqube-7.3]: /usr/java/jdk1.8.0_11/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/tools/sonarqube-7.3/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:/tools/sonarqube-7.3/lib/jdbc/mysql/mysql-connector-java-5.1.46.jar org.sonar.server.app.WebServer /tools/sonarqube-7.3/temp/sq-process9015419538083373362properties2018.10.16 11:20:30 INFO app[][o.s.a.SchedulerImpl] Process[web] is up
2018.10.16 11:20:30 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='ce', ipcIndex=3, logFilenamePrefix=ce]] from [/tools/sonarq
ube-7.3]: /usr/java/jdk1.8.0_11/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/tools/sonarqube-7.3/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:/tools/sonarqube-7.3/lib/jdbc/mysql/mysql-connector-java-5.1.46.jar org.sonar.ce.app.CeServer /tools/sonarqube-7.3/temp/sq-process8530700600938467792properties2018.10.16 11:20:42 INFO app[][o.s.a.SchedulerImpl] Process[ce] is up
2018.10.16 11:20:42 INFO app[][o.s.a.SchedulerImpl] SonarQube is up
[root@jason ~]# tail -30f /tools/sonarqube-7.3/logs/es.log
2018.10.16 11:19:56 INFO es[][o.e.n.Node] initializing ...
2018.10.16 11:19:57 INFO es[][o.e.e.NodeEnvironment] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [7.5gb], net total_space
[16.9gb], spins? [unknown], types [rootfs]2018.10.16 11:19:57 INFO es[][o.e.e.NodeEnvironment] heap size [495.3mb], compressed ordinary object pointers [true]
2018.10.16 11:19:57 INFO es[][o.e.n.Node] node name [sonarqube], node ID [biGYGRPKTfuUgAa7Ka6_bA]
2018.10.16 11:19:57 INFO es[][o.e.n.Node] version[5.6.3], pid[7224], build[1a2f265/2017-10-06T20:33:39.012Z], OS[Linux/3.10.0-862.9.1.el7.x8
6_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_11/25.11-b03]2018.10.16 11:19:57 INFO es[][o.e.n.Node] JVM arguments [-XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiati
ngOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -Xms512m, -Xmx512m, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/tools/sonarqube-7.3/elasticsearch]2018.10.16 11:19:57 INFO es[][o.e.p.PluginsService] loaded module [aggs-matrix-stats]
2018.10.16 11:19:57 INFO es[][o.e.p.PluginsService] loaded module [ingest-common]
2018.10.16 11:19:57 INFO es[][o.e.p.PluginsService] loaded module [parent-join]
2018.10.16 11:19:57 INFO es[][o.e.p.PluginsService] loaded module [percolator]
2018.10.16 11:19:57 INFO es[][o.e.p.PluginsService] loaded module [reindex]
2018.10.16 11:19:57 INFO es[][o.e.p.PluginsService] loaded module [transport-netty4]
2018.10.16 11:19:57 INFO es[][o.e.p.PluginsService] no plugins loaded
2018.10.16 11:20:00 INFO es[][o.e.d.DiscoveryModule] using discovery type [zen]
2018.10.16 11:20:01 INFO es[][o.e.n.Node] initialized
2018.10.16 11:20:01 INFO es[][o.e.n.Node] starting ...
2018.10.16 11:20:02 INFO es[][o.e.t.TransportService] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001}
2018.10.16 11:20:02 WARN es[][o.e.b.BootstrapChecks] max file descriptors [4096] for elasticsearch process is too low, increase to at least
[65536]2018.10.16 11:20:02 WARN es[][o.e.b.BootstrapChecks] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262
144]2018.10.16 11:20:05 INFO es[][o.e.c.s.ClusterService] new_master {sonarqube}{biGYGRPKTfuUgAa7Ka6_bA}{LS_FmahOSBeh2VAzSqbAbw}{127.0.0.1}{127.
0.0.1:9001}{rack_id=sonarqube}, reason: zen-disco-elected-as-master ([0] nodes joined)2018.10.16 11:20:05 INFO es[][o.e.n.Node] started
2018.10.16 11:20:05 INFO es[][o.e.g.GatewayService] recovered [8] indices into cluster_state
2018.10.16 11:20:07 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[co
mponents][2], [metadatas][0]] ...]).
http://192.168.199.251:9000
默认账户:admin
密码 :admin
汉化
生成SonarQube身份验证令牌
Jenkins和sonarqube集成
1.安装插件
2.系统管理--系统设置
系统管理--全局工具设置
3.配置sonar-scan-2.8的sonar-scanner.properties配置文件
root@jason sonar-scanner-2.8]# cat conf/sonar-scanner.properties |grep -Ev '^$|^#' sonar.host.url=http://192.168.199.251:9000
sonar.sourceEncoding=UTF-8
sonar.jdbc.username=root
sonar.jdbc.password=jason_zhang
sonar.jdbc.url=jdbc:mysql://192.168.199.251:3306/sonar?useUnicode=true&characterEncoding=utf8
配置sonar-scanner
cd /tools/sonar-scanner-2.8/bin/
vim sonar-scanner
将
if [ -n "$JAVA_HOME" ]
then
JAVA_CMD="$JAVA_HOME/bin/java"
else
JAVA_CMD="`which java`"
fi 修改为
if [ -n "$JAVA_HOME" ]
then
JAVA_CMD="/usr/bin/java"
else
JAVA_CMD="`which java`"
fi
将sonar-scanning-examples-master.zip测试源码放入Jenkins的test项目目录并解压
[root@jason workspace]#cd /var/lib/jenkins/workspace
[root@jason workspace]# ls
jason jason_test maven sw.test.c5game.cn.tar.gz test web
[root@jason workspace]# cd test/
[root@jason test]# ls
copybooks coverage-report sonar-project.properties src
编辑sonar-project.properties
sonar.projectKey=test
sonar.projectName=test
sonar.projectVersion=1.0 #sonar.sources=src,copybooks
sonar.sources=src,copybooks
# Language sonar.sourceEncoding=UTF-8 ## Cobol Specific Properties # comma-separated paths to directories with copybooks
sonar.cobol.copy.directories=copybooks
# comma-separated list of suffixes
sonar.cobol.file.suffixes=cbl,cpy
sonar.cobol.copy.suffixes=cpy ## Flex Specific Properties # retrieve code coverage data from the Cobertura report
sonar.flex.cobertura.reportPath=coverage-report/coverage-cobertua-flex.xml # PL/I Specific Properties
sonar.pli.marginLeft=2
sonar.pli.marginRight=0
chmod 777 sonar-project.properties
修改Jenkins的test项目配置
Analysis properties里面填写的就是sonar-project.properties的内容
返回test项目,点击构建,成功后可以看到
点击sonarqube跳转到
以上这个是项目源存在于Jenkins服务器的情况,假如项目源和Jenkins不在同一台服务器上
客户机 192.168.199.224
思路:在工程中配置好sonar-project.properties后,直接bash调用进入到工程中,执行sonar-scan也是可以的,因为sonar-scan就是依据sonar-project.properties来执行的,和界面填写,效果一样)
上传sonar-scan客户端和测试源码到该服务器的tools文件夹
[root@jason tools]# unzip sonar-scanning-examples-master.zip
[root@jason tools]# unzip sonar-scanner-2.8.zip
[root@jason tools]# mv sonar-scanning-examples-master jason_zhang 修改sonar-scanner-2.8.zip的sonar-scanner.properties和sonar-scanner 同上
修改sonar-project.properties配置文件
[root@jason conf]# cd /tools/jason_zhang//sonarqube-scanner
[root@jason sonarqube-scanner]# cat sonar-project.properties |grep -Ev '^$|^#'
sonar.projectKey=jason_zhang
sonar.projectName=jason_zhang
sonar.projectVersion=1.0
sonar.sources=src,copybooks
sonar.sourceEncoding=UTF-8
sonar.cobol.copy.directories=copybooks
sonar.cobol.file.suffixes=cbl,cpy
sonar.cobol.copy.suffixes=cpy
sonar.flex.cobertura.reportPath=coverage-report/coverage-cobertua-flex.xml
sonar.pli.marginLeft=2
sonar.pli.marginRight=0
chmod -R 777 /tools/
ln -s /tools/sonar-scanner-2.8/bin/sonar-scanner /usr/bin/sonar-scanner
jenkins服务器安装插件 publish over ssh
系统管理--系统设置
创建jason_zhang项目并配置,注意路径
构建完成
登录sonarqube http://192.168.199.251:9000
sonar-project.properties配置参考https://my.oschina.net/jiangbianwanghai/blog/479285
sonar.projectKey=jason
sonar.projectName=jason
sonar.projectVersion=1.0
sonar.sources=/var/lib/jenkins/workspace/jason
sonar.language=js
sonar.sourceEncoding=UTF-8
开机自动启动sonarqube
vim /etc/rc.d/rc.local
su sonar
sh /tools/sonarqube-7.3/bin/linux-x86-64/sonar.sh start chmod +x /etc/rc.d/rc.local
如果使用root账户启动过之后再使用sonar账户使用也是会失败的,需要进入/tools/sonarqube-7.3/temp 清空该目录再使用sonar账户启动sonarqube
参考:
https://www.cnblogs.com/tongxiaoda/p/8484308.html
https://blog.csdn.net/weixin_41004350/article/details/78492533
https://blog.csdn.net/weixin_41004350/article/details/78491472 (安装Java)
http://tool.uml.com.cn/iWork/SonarQube.asp
https://www.cnblogs.com/weschen/p/6023153.html
https://segmentfault.com/a/1190000008716005
https://www.jianshu.com/p/4c6f9361565b (Elasticsearch 报错)
http://www.cnblogs.com/zndxall/archive/2018/07/19/9336879.html
https://www.cnblogs.com/parryyang/p/6270402.html
https://www.cnblogs.com/nmap/p/6792148.html
Jenkins+sonar7.3集成的更多相关文章
- Jenkins——构建、集成中的问题
准备 Jekins 安装插件 MsBuild Plugin Team Foundation Server Plug-in 配置环境变量 我的电脑中设置环境变量,Path中添加msbuild的路 ...
- 【iOS】Jenkins Gitlab持续集成打包平台搭建
Jenkins Gitlab持续集成打包平台搭建 SkySeraph July. 18th 2016 Email:skyseraph00@163.com 更多精彩请直接访问SkySeraph个人站点: ...
- 使用jenkins构建持续集成平台
jenkins + Maven + svn/git + tomcat 的持续集成平台 项目管理流程: 需求分析----原型设计----开发代码----提交测试-----内部测试-----确认上线( ...
- 用MSBuild和Jenkins搭建持续集成环境(2)
http://www.infoq.com/cn/articles/MSBuild-2 作者 Mustafa Saeed Haji Ali ,译者 李剑 发布于 2012年10月23日 | 注意: ...
- jenkins jmeter持续集成批处理jmx脚本
这篇文章介绍jenkis jmeter的持续集成,利用jenkins定时任务去批处理执行jmeter的jmx脚本文件,并且生成测试报告 1:jmeter的安装这里我就不在赘述了,如有问题可参考我的jm ...
- RF+Jenkins构建持续集成
引入RF是为了能够快速的开展自动化验收测试,Jenkins而一种持续集成工具,用于监控持续重复的工作,持续的软件版本发布/测试项目,而通过RF+Jenkins可以有利的对RF构建的接口项目进行持续集成 ...
- Jenkins+Git 持续集成
持续集成是必要的! 希望达到的效果是:开发同事签入代码后,对应的站点可以自动实现更新.目前还只在在内部服务器上实现开发环境中的站点更新,不涉及到线上的发布. 目前使用Jenkins实现这样的持续集成. ...
- 使用Jenkins进行持续集成ionic3项目
Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. 网上大多数是关于.net web网站以及 ...
- 使用jenkins实现持续集成
一.jenkins 介绍 它是一个自动化的周期性的集成测试过程,从检出代码.编译构建.运行测试.结果记录.测试统计等都是自动完成的,无需人工干预: 它需要有专门的集成服务器来执行集成构建: 它需要有代 ...
随机推荐
- chrome也可以整张网页截图,保存完整网页为图片
转自:http://www.webkaka.com/blog/archives/chrome-save-a-webpage.html 关于浏览器截图,一直以为Chrome无能为力,最近发现,原来Chr ...
- Proftpd 服务器安装配置
yum install proftpd 如果提示没有找到源 rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6 ...
- DLL创建与调用(C#调用C++的DLL)
1.C++中需要导出的函数,函数定义处在返回值前加上:extern "C" __declspec(dllexport) C#调用:[DllImport("导出函数所在DL ...
- JEECG-P3首个开源插件诞生!CMS网站插件 Jeecg-p3-biz-cms1.0版本发布!
Jeecg-P3-Biz-Cms ( JEECG 首个微服务插件,支持小程序的CMS系统) 是基于JEECG-P3 微服务框架开发的CMS建站系统,可轻量级集成进jeecg系统,定制各类网站模板, ...
- day09-列表
1.列表的格式list与其他语言的数组相似,基础数据类型,可以存储各种数据类型,可以存储大量的数据,32位python可以存储2的29次方个元素,即536870912个元素,64位python的限制是 ...
- Delphi与各数据库数据类型比较
Delphi数据类型与各数据库数据类型对比如下表,如有具体说明见表中脚注: Delphi Type Oracle Types SQL Server Types MySQL Types [1] Inte ...
- Linux:使用互斥量进行线程同步
基础知识 同步概念 所谓同步,即同时起步,协调一致.不同的对象,对"同步"的理解方式略有不同.如,设备同步,是指在两个设备之间规定一个共同的时间参考:数据库同步,是指让两个或多个数 ...
- 3.有关于Python列表简述
一..title() [让所选择的列表元素的第一个字母大写] test = ['no1','No2','No3','No4'] book = "This My " + test[0 ...
- linux下安装Tomcat7.0
1.下载安装文件:Download apache-tomcat-7.0.14.tar.gz 下载1 下载 2.输入命令解压文件:tar - zxvf apach ...
- 【动态规划】最大子段和问题,最大子矩阵和问题,最大m子段和问题
http://blog.csdn.net/liufeng_king/article/details/8632430 1.最大子段和问题 问题定义:对于给定序列a1,a2,a3……an,寻找它 ...