Build a continuous integration environment based on Jenkins and build integration with jenkins

Source: Internet
Author: User
Tags tortoisesvn

Build a continuous integration environment based on Jenkins and build integration with jenkins

After reading the blog post of Zhang Shanyou from yuanyou, the attempt is successful. The original website:Http://www.cnblogs.com/shanyou/p/3750714.html

  What is the difficulty in the world? For this, it is easy for the hard person. If not, it is also difficult for the easy person.

 

First, you must learn to use MSBuild to build scripts.

Website:Http://www.infoq.com/cn/articles/MSBuild-1.

Objective: To compile a program using MSBuild, which is mainly used for asp.net or asp.net mvc.

Finally, I wrote the following script:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
	<BuildArtifactsDir Include="UI\bin\" />
	<SolutionFile Include="HelloCI.sln" />
</ItemGroup>

<PropertyGroup>
	<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
	<BuildPlatform Condition=" '$(BuildPlatform)' == '' ">Any CPU</BuildPlatform>
</PropertyGroup>


<Target Name="Init" DependsOnTargets="Clean">
	<MakeDir Directories="@(BuildArtifactsDir)" />
</Target>

<Target Name="Clean">
	<RemoveDir Directories="@(BuildArtifactsDir)" />
</Target>

<Target Name="Compile" DependsOnTargets="Init">
 <MSBuild Projects="@(SolutionFile)" Targets="Rebuild"
          Properties="OutDir=%(BuildArtifactsDir.FullPath);Configuration=$(Configuration);Platform=$(BuildPlatform)" />
</Target>

</Project>


<!--msbuild HelloCI.msbuild /t:Compile /p:VisualStudioVersion=12.0 -->

 

The last line of comments of the script is the build command./p: VisualStudioVersion = 12.0 indicates the version. If it is not specified, an error is returned and a file cannot be found.

 

Jenkins + tortoisesvn + MSBuild continuous integration

Use with Jenkins: http://www.infoq.com/cn/articles/MSBuild-2

First, read the article corresponding to the above URL. Note: The version controller I use is tortoisesvn. In addition, I will also explain the post-commit hook.

1. Install Jenkins (stable version). After installation, go to system management on the left. Click Manage ins to install the MSBuild ins.

2. Use Jenkins to create a free-style software project. The configuration is as follows:


 

It mainly configures the svn address and account password. You do not need to select the build trigger, and a hook will be used later.

Then build and configure as follows:


HelloCI. msbuild is the file name of the build script. Second, the parameter must be filled.

Save it directly.

Project List, such:


 

In this case, use svn to upload a project (excluding bin). The project root directory must contain the HelloCI. msbuild file.

After the upload is complete, click build now in. Use IIS and other software to check whether the website can be accessed.

If the build is successful, the next step is how to trigger the build. After all, every commit is performed, the build is performed on the server immediately, which is a repetitive action. To trigger the build, 'encapsulate '.

Trigger construction with tortoisesvn's post-commit hook

First, you must understand that in the Jenkins project list, in addition to clicking build now, you can also access

  Http: // localhost: 8080/job/JOBNAME/build? Delay = 0sec(JOBNAME must be replaced with the actual job name), and Jenkins starts the build. (Please test it by yourself. After passing the test, continue to see the following .)

Tortoisesvn hook settings are as follows:


 

What is HelloCIHook.exe? You can think of it as a small program. executing it will access the url that can trigger the building.

The Code is as follows:

    class Program
    {
        
        static void Main(string[] args)
        {
            const string url = "http://localhost:8080/job/HelloCI/build?delay=0sec";
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            req.Method = "GET";
            req.KeepAlive = false;
            req.GetResponse();
        }
    }

 

This is the end.

After the svndelivery code is used, the hook starts the hellocihook.exe program. The program accesses a url and triggers the Jenkins build (the execution of the MSBuild build script ). jenkins is built with the latest code library and generates files in the bin (or other) directory. the website is successfully updated.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.