Saturday, January 12, 2013

Create a Mono C# Buildserver using Jenkins and GitHub

Saturday, January 12, 2013 Posted by Andre Broers , , , , , , , , , 31 comments
My favourite development environment is Visual Studio. All my serverside code I develop in Visual Studio on my workstation. I have a homeserver with VMware ESXi where I run several linux instances. All my webprojects I host from this instances. To keep the cost low I run them on Linux. Same with my Continuous Integration setup. I use the Linux - Jenkins - Mono - Github combination to build my projects. In this post I will demo how to create this setup.

Install Linux Ubuntu Server 12.04

First thing to do is install a Linux server and call it build01. It needs a minimum of 1gb of memory (because to the java stuff :-)) Look at my previous blog post how to install ubuntu.

Install Git

sudo apt-get update
sudo apt-get install git

Install Mono

sudo apt-get update
sudo apt-get install mono-complete

Install Jenkins

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins


Now it is time to start jenkins for the first time. Open a browser and browse to http://build01:8080


Configure Jenkins

Now go to Manage Jenkins and select Manage Plugins. We need to install the MSBuild Plugin. Goto the tab Available and type msbuild in the Filter box. Select the plugin and click Download now and install after restart.


Install the GitHub Plugin the same way. This will also install two other dependent plugins.
After installing enable all the plugins in the same screen. This is an important step.

Now goto Manage Jenkins - Configure System. Here we configure de MSBuild plugin and add a new MSBuild installation:



This is the mono msbuild tool called xbuild. Now the msbuild step will use this build tool to build visual studio sollutions or other msbuild project files. Remember this tool is not completely compatible with msbuild from Microsoft, but I can build my Console Applications and Libraries with it. I use NancyFx for my webapplications and these projects build fine also.

Now it's time to create a new project in jenkins. I have a simple solution with a consoleapp in it that copies my photos in the right folder using exif information in github at: https://github.com/broersa/photorename.git .
This project doesn't use downloading nuget packages at build time, but this is also supported. xbuild will run nuget.exe and download nuget packages. It all works on mono.

At the jenkins dashboard click New Job. Name the job and select Build a free style job project and click Ok.


In the next screen enter the github project url in  the GitHub project box and select Git at the Source Code Management section. Fill in the Repository URL and scroll down to the build steps.


Now click the second Advanced button to open the Git advanced options.


 Now a whole of options open and we need to select the option skip internal tag.



Goto Build section and click Add build step. Select an MSBuild step.



Now select the mono installation we configured in the previous steps and fill in the solution of the project to build.


Click Save to save the project. Now we can build the C# Mono Visual Studio solution on Linux.
From the dashboard click our project and select Build Now. The project is now building.


We see a succesfull build and can now view the log to see what jenkins did to build the solution:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/photorename/workspace
Checkout:workspace / /var/lib/jenkins/jobs/photorename/workspace - hudson.remoting.LocalChannel@74ed41f8
Using strategy: Default
Cloning the remote Git repository
Cloning repository https://github.com/broersa/photorename.git
git --version
git version 1.7.9.5
Fetching upstream changes from https://github.com/broersa/photorename.git
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 980fc0b10f9dc29dd6b1f8e00037534dca240f01 (origin/HEAD, origin/master)
Checking out Revision 980fc0b10f9dc29dd6b1f8e00037534dca240f01 (origin/HEAD, origin/master)
No change to record in branch origin/HEAD
No change to record in branch origin/master
Path To MSBuild.exe: /usr/lib/mono/4.0/xbuild.exe
Executing the command /usr/lib/mono/4.0/xbuild.exe PhotoRename.sln from /var/lib/jenkins/jobs/photorename/workspace
[workspace] $ /usr/lib/mono/4.0/xbuild.exe PhotoRename.sln
XBuild Engine Version 2.10.8.1
Mono, Version 2.10.8.1
Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2011.

Build started 1/12/2013 5:36:22 PM.
__________________________________________________
Project "/var/lib/jenkins/jobs/photorename/workspace/PhotoRename.sln" (default target(s)):
 Target ValidateSolutionConfiguration:
  Building solution configuration "Debug|x86".
 Target Build:
  Project "/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/PhotoRename.csproj" (default target(s)):
   Target PrepareForBuild:
    Configuration: Debug Platform: x86
    Created directory "bin/Debug/"
    Created directory "obj/x86/Debug/"
   Target GetReferenceAssemblyPaths:
/usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Unable to find framework corresponding to the target framework moniker '.NETFramework,Version=v4.0,Profile=Client'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.
   Target ResolveAssemblyReferences:
/usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' not resolved
    For searchpath /var/lib/jenkins/jobs/photorename/workspace/packages/ExifLib.1.2.4436.20486/lib/net20
    Considered '/var/lib/jenkins/jobs/photorename/workspace/packages/ExifLib.1.2.4436.20486/lib/net20/mscorlib' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/packages/ExifLib.1.2.4436.20486/lib/net20/mscorlib.exe' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/packages/ExifLib.1.2.4436.20486/lib/net20/mscorlib.dll' as a file, but the file does not exist
    For searchpath {CandidateAssemblyFiles}
    Warning: {CandidateAssemblyFiles} not supported currently
    For searchpath {HintPathFromItem}
    HintPath attribute not found
    For searchpath {TargetFrameworkDirectory}
    For searchpath {PkgConfig}
    Considered mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, but could not find in any pkg-config files.
    For searchpath {GAC}
    Considered mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, but could not find in the GAC.
    For searchpath {RawFileName}
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' as a file, but the file does not exist
    For searchpath bin/Debug/
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/mscorlib' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/mscorlib.exe' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/mscorlib.dll' as a file, but the file does not exist
/usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' not resolved
    For searchpath /var/lib/jenkins/jobs/photorename/workspace/packages/NDesk.Options.0.2.1/lib
    Considered '/var/lib/jenkins/jobs/photorename/workspace/packages/NDesk.Options.0.2.1/lib/mscorlib' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/packages/NDesk.Options.0.2.1/lib/mscorlib.exe' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/packages/NDesk.Options.0.2.1/lib/mscorlib.dll' as a file, but the file does not exist
    For searchpath {CandidateAssemblyFiles}
    Warning: {CandidateAssemblyFiles} not supported currently
    For searchpath {HintPathFromItem}
    HintPath attribute not found
    For searchpath {TargetFrameworkDirectory}
    For searchpath {PkgConfig}
    Considered mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, but could not find in any pkg-config files.
    For searchpath {GAC}
    Considered mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, but could not find in the GAC.
    For searchpath {RawFileName}
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' as a file, but the file does not exist
    For searchpath bin/Debug/
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/mscorlib' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/mscorlib.exe' as a file, but the file does not exist
    Considered '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/mscorlib.dll' as a file, but the file does not exist
/usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Found a conflict between : 'System' and 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System' reference.
   Target CopyFilesMarkedCopyLocal:
    Copying file from '/var/lib/jenkins/jobs/photorename/workspace/packages/ExifLib.1.2.4436.20486/lib/net20/ExifLib.dll' to '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/ExifLib.dll'
    Copying file from '/var/lib/jenkins/jobs/photorename/workspace/packages/NDesk.Options.0.2.1/lib/NDesk.Options.dll' to '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/NDesk.Options.dll'
   Target GenerateSatelliteAssemblies:
   No input files were specified for target GenerateSatelliteAssemblies, skipping.
   Target CoreCompile:
    Tool /usr/bin/dmcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/x86/Debug/PhotoRename.exe Program.cs Properties/AssemblyInfo.cs /target:exe /define:"DEBUG;TRACE" /platform:x86 /reference:../packages/ExifLib.1.2.4436.20486/lib/net20/ExifLib.dll /reference:../packages/NDesk.Options.0.2.1/lib/NDesk.Options.dll /reference:/usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll /reference:/usr/lib/mono/gac/System.Xml.Linq/4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll /reference:/usr/lib/mono/gac/System.Data.DataSetExtensions/4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/gac/Microsoft.CSharp/4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll /reference:/usr/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll /reference:/usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll /reference:/usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll /warn:4
Program.cs(18,18): warning CS0219: The variable `verbose' is assigned but its value is never used
Program.cs(25,26): warning CS0219: The variable `extra' is assigned but its value is never used
   Target DeployOutputFiles:
    Copying file from '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/obj/x86/Debug/PhotoRename.exe.mdb' to '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/PhotoRename.exe.mdb'
    Copying file from '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/obj/x86/Debug/PhotoRename.exe' to '/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/bin/Debug/PhotoRename.exe'
  Done building project "/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/PhotoRename.csproj".
Done building project "/var/lib/jenkins/jobs/photorename/workspace/PhotoRename.sln".

Build succeeded.

Warnings:

/var/lib/jenkins/jobs/photorename/workspace/PhotoRename.sln (default targets) ->
(Build target) ->
/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/PhotoRename.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.Common.targets (GetReferenceAssemblyPaths target) ->

 /usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Unable to find framework corresponding to the target framework moniker '.NETFramework,Version=v4.0,Profile=Client'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.

/var/lib/jenkins/jobs/photorename/workspace/PhotoRename.sln (default targets) ->
(Build target) ->
/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/PhotoRename.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.Common.targets (ResolveAssemblyReferences target) ->

 /usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' not resolved
 /usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' not resolved
 /usr/lib/mono/4.0/Microsoft.Common.targets:  warning : Found a conflict between : 'System' and 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using 'System' reference.

/var/lib/jenkins/jobs/photorename/workspace/PhotoRename.sln (default targets) ->
(Build target) ->
/var/lib/jenkins/jobs/photorename/workspace/PhotoRename/PhotoRename.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->

 Program.cs(18,18): warning CS0219: The variable `verbose' is assigned but its value is never used
 Program.cs(25,26): warning CS0219: The variable `extra' is assigned but its value is never used

  6 Warning(s)
  0 Error(s)

Time Elapsed 00:00:01.1354710
Finished: SUCCESS





31 comments:

  1. Simply want to say your article is as amazing.

    The clearness for your publish is just excellent and i can think you're knowledgeable in this subject. Well along with your permission allow me to snatch your RSS feed to stay up to date with coming near near post. Thanks one million and please carry on the enjoyable work.
    Feel free to surf my blog :: fat loss

    ReplyDelete
  2. What's up Dear, are you truly visiting this site regularly, if so after that you will definitely take fastidious know-how.
    Also visit my webpage ... Special Effect Photography

    ReplyDelete
  3. It is in point of fact a nice and useful piece of information.
    I am glad that you simply shared this useful info with us.
    Please keep us up to date like this. Thanks for sharing.



    Also visit my weblog cccamdaddy review

    ReplyDelete
  4. I like it when people get together and share views. Great site, stick with
    it!

    Also visit my site - Air Max

    ReplyDelete
  5. We're a group of volunteers and opening a brand new scheme in our community. Your site offered us with helpful info to work on. You have performed a formidable process and our entire group will likely be grateful to you.

    Review my web page ... www.tedxyse.com

    ReplyDelete
  6. whoah this weblog is excellent i love reading your posts.

    Keep up the great work! You understand, a lot of individuals are
    looking round for this information, you can aid them greatly.


    Look into my web site: ngosummit.com

    ReplyDelete
  7. I read this post fully on the topic of the resemblance of hottest and previous technologies,
    it's amazing article.

    my website: NFL wholesale Jerseys **

    ReplyDelete
  8. Thanks for sharing such informative guide on .Net technology. This post gives me detailed information about the .net technology. I am working as trainer in leading IT training academy offering Dot Net Training in Chennai and i use your guide to educate my students.

    ReplyDelete
  9. Thanks for your informative blog!!! Your article helped me to understand the future of .net programming language. Keep on updating your with such awesome information. .net training | dot net course Chennai

    ReplyDelete

  10. I like your writing style, it was very clear to understanding the concept well; I hope you ll keep your blog as updated.
    Regards,
    Angular training in chennai|Angularjs training in chennai

    ReplyDelete
  11. Thank you so much. I had no experience, but I set up Jenkins on my Raspberry Pi for 30 minutes according to your instructions.
    Build cross-platform project was successful. It's amazing :)

    ReplyDelete
  12. most of the Multi-Level IVR configurationto select an extension number and name for your new IVR menu in this site Multi-level ivr plugin ,,so click this site

    ReplyDelete
  13. This blog is so nice to me. I will continue to come here again and again. Visit my link as well. Good luck
    http://www.jualobataborsiherbal.com/ obat aborsi
    http://caramenggugurkankandungan.info/ cara menggugurkan kandungan
    http://www.jualobataborsiherbal.com/cara-menggugurkan-kandungan/ cara menggugurkan kandungan
    http://obataborsi59.com/ obat aborsi
    http://obataborsi59.com/cara-menggugurkan-kandungan-dengan-cepat-dan-aman/ cara menggugurkan kandungan
    http://obattelatdatangbulan.info/ obat telat datang bulan
    http://klinikobataborsi.com/ jual obat aborsi
    http://jualobatpenggugurkandungan.net/ obat penggugur kandungan
    http://tandatandakehamilan.net/ tanda tanda kehamilan
    http://tandatandakehamilan.net/cara-cepat-dan-selamat-menggugurkan-kandungan/ cara menggugurkan kandungan

    ReplyDelete
  14. من منا لا يدرك أهمية الغاز!!؛ فتواجده في المؤسسات والمصانع والمنازل؛
    أمر لابد منه بلا منازع؛ وذلك لأهمية تواجده القصوى؛ فمعظم المؤسسات والمصانع تستخدم الغاز المركزي
    ؛ لتلبية كافة حاجياتها الضرورية واليومية لاستخدامات الغاز؛
    ونظرا لأهمية الغاز؛ فهناك العديد من شركات تمديد الغاز المركزى؛ أخذت على عاتقها تقديم خدمات تمديد خطوط الغاز المركزى؛ وصيانه خطوط الغاز
    ؛ وكشف تسربات الغاز؛ بالإضافة إلى إصلاح خطوط الغاز؛
    ولكن معظم شركات تمديد الغاز المركزى بالرياض؛ لا تقدم كل هذه الخدمات بجودة عالية؛ وبأسعار خيالية
    ؛ مما يجعلك تطلب خدمة صيانه خطوط الغاز؛ أو كشف تسربات الغاز
    ؛ وإصلاح خطوط الغاز؛ من شركة تمديد الغاز أخرى؛ تضمن لك تقديم خدمات عالية الجودة؛ وذلك لتفادي مخاطر الغاز.

    شركة تمديد الغاز المركزى بالرياض
    تمديد الغاز المركزى بالرياض
    تمديد الغاز المركزى
    شركة تمديد الغاز
    اصلاح خطوط الغاز
    كشف تسربات الغاز

    ReplyDelete
  15. dai ly vietnam airlines xin được tư vấn cho du khách cách đặt mua ve may bay di nga giá rẻ để bạn có thể đến với xứ sở bạch dương xinh đẹp. Nếu bạn là người yêu thích sự năng động và hiện đại của đảo quốc sư tử thì còn chần chừ gì mà không sở hữu nagy tấm ve may bay di singapore.
    Với nền văn hóa đặc sắc, đất nước Thái lan chính là một điểm đến tuyệt vời dành cho du khách muốn khám phá nền Phật Giáo lâu đời tại đây, hãy đặt ve may bay di thai lan ngay hôm nay
    Hoa Kỳ là một trong những quốc gia mơ ước của các tín đồ du lịch, bạn có thể đặt mua ve may bay di my hoặc ve may bay di my gia re
    Không chỉ có những địa danh nổi tiếng của Thế Giới, mùa hè này bạn cũng có thể đến với những địa danh nổi tiếng của việt nam như Nha Trang, Phú Quốc, Đà Nẵng bằng cách nhanh tay đặt mua vé giá rẻ tại:
    - ve may bay di nha trang
    - ve may bay di phu quoc
    - ve may bay di da nang hoặc ve may bay di da nang gia re

    ReplyDelete
  16. شركة عباد الرحمن بفضل الله تعالى تخصصنا فى نقل العفش داخل السعودية وخارجها ومتخصصون فى نقل عفش جدة وذلك لما نمتلكه من خبرة واسعة وانتشار واسع داخل احياء جدة وذلك لنقل الاثاث وتخزين العفش بالاضافة الى كافة الخدمات المنزلية
    نقل عفش
    ارخص شركات نقل العفش بجدة
    ارخص شركات نقل العفش فى جدة
    نقل عفش جدة
    شركة نقل عفش جدة
    افضل شركات نقل العفش بجدة
    شركة نقل عفش رخيصة
    ارخص شركة نقل عفش
    ارخص شركات نقل العفش بجدة

    http://ebad-rahman.blogspot.com
    نقل عفش - عباد الرحمن 0535220955
    http://ebad-rahman.blogspot.com/2017/02/transfer-jeddah.html
    نقل عفش ,نقل عفش بجدة , ارخص شركات نقل العفش , ارخص شركات نقل العفش بجدة , نقل عفش بجدة رخيصة , اسعار شركات نقل العفش بجدة , نقل عفش الرياض, نقل عفش الدمام, نقل عفش تبوك, نقل عفش داخل جدة, نقل عفش 300, نقل عفش داخلى,دليل شركات نقل العفش , نقل عفش جدة ومكة
    http://ebad-rahman.blogspot.com/2017/03/nakl-afsh-JEDDAH.html
    https://www.youtube.com/watch?v=_9kiCpwQI0Q
    https://www.instagram.com/ebad__rahman1
    https://www.facebook.com/ebadrahmannn
    http://ebad-rahman.blogspot.com/rss.xml
    متخصص فى نقل العفش وتخزين الاثاث وتقديم كافة الخدمات المنزلية من تظيف منازل ومفروشات ومكافحة حشرات ورش مبيدات وتنظيف المسابح والخزانات وكشف تسريبات المياه اتصل الان 0535220955

    ReplyDelete