您的位置:首页 > 其它

老李分享:持续集成学好jenkins之Git和Maven配置

2015-12-15 13:24 579 查看

老李分享:持续集成学好jenkins之Git和Maven配置

poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。如果对课程感兴趣,请大家咨询qq:908821478 Jenkins专用术语,请参考下面连接:https://wiki.jenkins-ci.org/display/JENKINS/Terminology 1.通过Jenkins web页面添加Git pluginManage Jenkins->Manage Plugins->Available中选择Git Plugin安装,注意要填写user name和 email地址,否则日后会碰到git tag的错误2.Jenkins服务器上创建Git用户所需公钥具体步骤参考Git server文章http://blog.csdn.net/sheismylife/article/details/7204345注意,要将最后生成的.ssh目录下的公钥和私钥文件复制到/var/lib/jenkins/.ssh目录下,否则git clone命令会报错3.修改jenkins目录权限chmod -R 777 /var/lib/jenkins4.通过web页面创建一个项目Test,然后设置该项目使用Git作为版本管理。并且设置repository路径,比如:git@S1:cml.git5.在build选项的pom文件指定你需要执行的pom.xml路径比如一个测试工程名叫client,是个maven工程,设置为client/pom.xml6.现在可以点击左侧的Build now进行测试一切OK,则没有错误日志。在Build History中可以看到测试结果,有没有错误。7.Email发送设置在Manage Jenkins->Configure System->Email Notification中,设置SMTP发送的基本信息,点击Advanced,可以填写用户名和密码。还有一个测试按钮可以用来发送测试设置是否正确。同时在Test项目中的Building Settings打勾选中E-mail Notification,点击右边的问号,会出现帮助文档,说明在四种情况下会发送email,填写接受email的地址,然后故意将client代码修改到不能编译通过。然后点击Build now按钮测试一下。果然收到email.8.检查代码更新并编译可以通过Poll SCM来设置定时检查编译功能比如*/5 * * * * 就是每隔5分钟检查一次,如果git仓库中有更新,则执行build操作。9.使用Maven私服加快下载速度参阅:http://blog.csdn.net/sheismylife/article/details/7209722Jenkins的.m2目录路径在:/var/lib/jenkins/.m2/先清空所有jar包,后创建settings.xml文件,编辑内容如下:<settings> <mirrors> <mirror> <!--This sends everything else to /public --> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://S1:8081/nexus/content/groups/public</url> </mirror> </mirrors> <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> <!--make the profile active all the time --> <activeProfile>nexus</activeProfile> </activeProfiles></settings>现在点击build now测试一下,打开console output,看看命令行输出结果,如果发现从S1下载jar包,就正确。和不用私服的比较了一下,节省了1分多钟.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  软件测试开发