⑴ 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 * * * * 表示每五分鍾構建一次