⑴ jenkins git+maven 编译怎么知道编译成功
1.通过Jenkins web页面添加Git plugin
Manage Jenkins->Manage Plugins->Available中选择Git Plugin安装,
注意要填写user name和 email地址,否则日后会碰到git tag的错误
2.在Jenkins使用的机器上创建Git用户所需要的公钥
具体步骤参考前面Git server文章
但是注意,要将最后生成的.ssh目录下的公钥和私钥文件复制到/var/lib/jenkins/.ssh目录下,否则git clone命令会报错
3.修改jenkins目录权限
chmod -R 777 /var/lib/jenkins
4.现在可以通过web页面创建一个项目Test,然后设置该项目使用Git作为版本管理。
并且设置repository路径,比如我的:git@S1:cml.git
5.在build选项的pom文件指定你需要执行的pom.xml路径
比如我的一个测试工程名叫client,是个maven工程,我设置为client/pom.xml
6.现在可以点击左侧的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加快下载速度
如我这篇文章所述,用可以避免下载过慢问题,也可以绕过公司内部外网限制问题。
Jenkins的.m2目录路径在:/var/lib/jenkins/.m2/
首先清空里面所有的jar包,然后创建settings.xml文件,并编辑内容如下:
源码打印?
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url></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></url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url></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分多钟.
⑵ 如何用jenkins自动生成nuget包
关于NuGet的介绍已经很多,可以参考下面的:
NuGet学习笔记(1)——初识NuGet及快速安装使用 http://kb.cnblogs.com/page/143190/
NuGet学习笔记(2)——使用图形化界面打包自己的类库 http://kb.cnblogs.com/page/143191/
NuGet学习笔记(3)——搭建属于自己的NuGet服务器 http://kb.cnblogs.com/page/143192/
上面的文章介绍了搭建Web版本的NuGet服务器以及用图形化的方式生成NuGet包。
用NuGet.Server管好自家的包包 http://www.cnblogs.com//archive/2012/06/05/nuget_server_push.html
上面的文章介绍了搭建Web版本的NuGet服务器,以及自动化生成NuGet包的方法
本文介绍简单的NuGet服务器,以及VS2013自动化生成NuGet包的内容。
一、VS自动生成NuGet包
1、在VS中创建类库项目
2、启用NuGet程序包还原(Enable
NuGet Package Restore)
在解决方案上右击,选择“启用NuGet程序包还原”
确定后会在解决方案中增加一个“.nuget"文件夹,该文件夹有三个文件。
此时,打开项目文件ClassLibrary1.csproj,可以看到类似下面的内容,注意:下面绿色背景行的内容是否出现在ClassLibrary1.csproj中
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists(‘$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props‘)" />
<PropertyGroup>
<Configuration Condition=" ‘$(Configuration)‘ == ‘‘ ">Debug</Configuration>
<Platform Condition=" ‘$(Platform)‘ == ‘‘ ">AnyCPU</Platform>
<ProjectGuid>{92A6F604-9829-49FB-8B06-FF2E4C757EC4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClassLibrary1</RootNamespace>
<AssemblyName>ClassLibrary1</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == ‘‘ Or $(SolutionDir) == ‘*Undefined*‘">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)‘ == ‘Debug|AnyCPU‘ ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)‘ == ‘Release|AnyCPU‘ ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists(‘$(SolutionDir)\.nuget\NuGet.targets‘)" />
<Target Name="" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists(‘$(SolutionDir)\.nuget\NuGet.targets‘)" Text="$([System.String]::Format(‘$(ErrorText)‘, ‘$(SolutionDir)\.nuget\NuGet.targets‘))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
如果没有出现带加号行的内容,需要手动添加上。
第2块绿背景内的代码创建了对.nuget文件夹下的NuGet.targets文件的引用,并添加了缺少NuGet.targets文件的错误信息。
第1块绿背景内的第1行代码创建了SolutionDir 并设置默认值为项目的父目录,NuGet.targets利用这个配置值来找到他需要的NuGet.exe等资源。
第二行代码,RestorePackages被设置为True。
3、设置BuildPackages
2中启用了NuGet还原,但是还需要设置让NuGet自动生成nupkg包文件,用记事本打开.csproj文件添加下面1行语句
<BuildPackage>true</BuildPackage>
到1下一行的话,Debug和Release编译均生成包
到2下一行的话,只用Debug编译才生成包
到3下一行的话,只用Release编译才生成包
4、编译
编译后就可以再bin文件夹下看到.nupkg文件了
⑶ 请问Jenkins如何配置自动或定时编译
打开job的配置界面,在构建触发器栏下有Poll SCM(定时检查源码变更并构建)和Build periodically(周期进行项目构建,不关心源码是否变更)选择,打开它们后面的问号,有很明确的介绍和实例
⑷ jenkins 怎么配置git 编译android 源码工程
下载下的 manifest 才17.2k 都没有相关的代码文件啊! 怎么搞的呢??? 查看原帖>>
⑸ 如何 编译 jenkins 插件
系统管理--管理插件--高级--浏览-上传插件即可 会提示重启jenkins,--重启后插件安装成功 下载的插件是.zip格式的,改成.hpi后缀名即可
⑹ jenkins git怎么自动编译工程
当时也是花费了不少时间来配置Jenkins自动打包的问题,觉得还是需要记录一下。 1.安装Jenkins,这个很简单,不需要多说。 2.下载Git Plugin,Gradle Plugin,Android Emulator Plugin(这个可以配置SDK路径,觉得这个插件挺好)
⑺ jenkins控制台输出编译错误怎么回事
1、 设置jenkins所在服务器环境变量,右键我的电脑→属性→高级系统设置→环境变量,添加JAVA_TOOL_OPTIONS
2、修改Tomcat配置,进入apache_tomcat/conf文件夹下,编辑server.xml,在Connector port="8080"后面加入useBodyEncodingForURI="true"
<Connector port="8080" useBodyEncodingForURI="true" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
3、启动tomcat,运行jenkins,进入系统管理→系统设置,在全局属性处勾选Environment variables,添加编码环境变量LANG=zh_CN.UTF-8
⑻ 如何利用jenkins来做android自动化
首先搭建起jenkins环境,android官方提供了使用ant编译打包的脚本,所以要在jenkins系统配置里面将ant配置好;然后在jenkins里面新建一个项目,这里列出比较重要的几项配置:
1、项目源代码位置,一般就是指定svn吧
2、构建过程添加shell,写入如下命令:
android update project -t ? -p ? -n ? (其中第一个问号处填写要使用的androidAPI版本,可在命令行中用android list target获得,第二个问号处填写项目目录,当前目录的话就用 . 表示,第三个问号是填写项目名称)
3、然后添加ant调用,最好要会ant的基础使用
这几个配置都是为了能将源代码打包成apk文件,打包完成后,可以再次调用shell,连接设备或者打开模拟器,安装应用,执行你的自动化脚本。
⑼ 如何设置jenkins 在摸个特定的时间编译
进入项目 配置 - 构建触发器 勾选Poll SCM 在日程表中写上你要构建的时间 列如*/5 * * * * 表示每五分钟构建一次