Copyright Disclaimer: During reprinting, please use hyperlinks to indicate the original source and author information of the article and this statement
Http://bigwhite.blogbus.com/logs/27940065.html
My project has been using C language as the main development language. Unlike Java and other emerging languages, my colleagues in the Group seem not so interested in new things, there is no willingness or consciousness to study new things with the initiative. I am so worried that I can't sit down again when I see so many wonderful tools in the outside world. I have always had a lot of ideas, but due to my limited energy, I was unable to make full use of myself. I used to give it to others, but the results were not very good. After realizing this, I decided to do it myself to improve my health.
From the bottom of my heart, I have been in conflict with the company's cmme process. Seeing agile development and Other lightweight development processes in the outside world grow increasingly, I still have to follow various complicated processes every day, there is a feeling of "being in Cao Ying's heart in Han. However, how can we accept agile ideas in a company with cmme streaming "senyan? I want you to see the different effects of new practices, and you will naturally be able to accept them. On infoq, some people also gave a suggestion: "Don't speak up with big terms (such as scrum or XP ). We recommend that you use cmme X-level "self-improvement" as the flag, find waste links in the Organization, and introduce best practices to eliminate waste. There is no need to talk about agility ". Continuous integration is also the preferred practice in the article, which is consistent with my thoughts.
Continuous integration has never been done before. I tried it in a project team of a department. I wrote my own scripts to complete the tasks of regularly updating code and building. Then, due to project shortage, it does not seem to have received good results. I also promoted the practice of continuous integration by my java colleagues in the project team, and arranged for a colleague to build the cruisecontrol server. However, it seemed that I was no longer enough, it is also strange that I did not give full attention and pressure in the future. I often think about these lessons? Is it so difficult to promote the practice of continuous integration? This time I did it myself, starting with C developers.
Continuous integration requires good tool support. The most well-known continuous integration tool in the industry is cruisecontrol, which occupies the No. 1 position in the Java development field, the design concept also affects the development of continuous integration tools. But when I think of Java, I first think it is complex. Will cruisecontrol be as complicated as configuring a web server? In addition, cruisecontrol uses a combination of Maven + ant + CVS/subversion. I have studied ant, Maven, and a large number of XML configurations, which makes me feel a headache, in addition, whether it works well with C/C ++ is also a question. In this way, I did not continue to use the cruisecontrol path. I tried to find a tool that is easy to configure and can be quickly used, and its core functions are not inferior to the cruisecontrol tool of thoughtworks. RB enters my field of view.
I have been paying attention to thoughtworks because I used to work there with two colleagues in the former Department. In addition, the products released by thoughtworks have really interests me. I have studied mingle before, however, mingle charges fees, and the performance still needs to be improved. Cruisecontrol. rb (hereinafter referred to as CC. RB) is an open-source product of thoughtworks. A short article on its homepage is very appealing to me: "continuous integration isn't rocket science. we keep it simple. ". Simplicity is exactly what I expected.
At present, the latest version of CC. Rb is 1.3.0, download is a compressed package: cruisecontrolrb-1.3.0.tgz. After decompression, A cruisecontrolrb-1.3.0 directory will appear in your current directory. Cc. rb has very few dependencies. You only need to install the ruby and SVN clients on your Integration Server. Note: the path of the executable programs of Ruby and SVN needs to be added to the path of your environment variable, otherwise CC. RB will not be able to find Ruby and SVN. Currently, CC. RB only supports SVN, and other version management tools are not yet supported. After all, CC. Rb is still young and has little development time, so it is quite understandable.
Now cc. Rb has been installed. That's right! Cc. Rb is implemented in Ruby, and Ruby is a script language without compilation. Now you can go to the cruisecontrolrb-1.3.0 directory and execute "Cruise -- version" (on a unix host, You Need To chmod the cruise file first, otherwise the cruise will not have execution permissions ), you will see:
Cruisecontrol. RB, version 1.3.0
Copyright (c) 2007 thoughtworks
Now you can add and configure your project. Let's talk about CC. by default, Rb places your project data in $ (home )/. under cruise/, if you are on Windows, project data will be stored in c: \ Documents ents and Settings \ user_name \ by default \. under cruise. It's easy to add a proj, as long as you provide enough information: Go to the cruisecontrolrb-1.3.0 directory and execute the command:
Cruise add proj_name -- URL svn_url -- username user_name -- password pass_word. If your SVN database has permission management, you need to provide user and passwd. Example: Cruise add test_proj -- url svn: // 192.168.0.2: 3999/trunk/test_proj -- username Tony -- password Tony
In this case, you are at $ (home )/. A test_proj project is created under cruise/projects. If the information you provide is correct, CC. RB will generate the latest code checkout in your SVN repository during initial project creation, and place it at $ (home )/. under cruise/projects/test_proj/work.
After completing the previous step, several configuration files under the $ (home)/. Cruise directory need to be focused on:
$ (Home)/. Cruise
-Config/site_config.rb
-Projects/test_proj/cruise_config.rb
$ (Home )/. the site_config.rb file under cruise/config is a global configuration file, whether you are in a CC. create several proj under RB. These proj will share the configuration, and the CC needs to be restarted after each configuration modification. RB takes effect. This file has two major configurations:
1) email server configuration
If you want to send the result of each build to relevant stakeholders through mail, you need to configure your mail server information.
Actionmailer: Base. smtp_settings = {
: Address => "xx. xx ",
: Port => 25, # The default SMTP port on the server is 25.
: Domain => "your_domain.com ",
: Authentication =>: Plain,
: User_name => "your_user_name ",
: Password => "your_passwd"
}
2) dashboard URL
Configuration. dashboard_url = 'HTTP: // ip: port'; the dashboard URL will be added to the mail sent to the stakeholders, after receiving the mail, the stakeholders can directly click the URL to log on to CC. view related content on the RB dashboard. The configuration file for CC. Rb is also applicable to the ruby language. The ruby language syntax is relatively simple and I believe everyone can understand it.
$ (Home )/. the cruise_config.rb file under cruise/projects/test_proj is a local configuration file of project-specific. It is dynamically updated and your updates take effect immediately during the next build. The content in this configuration file is very important and practical:
1) project. email_notifier.emails = ['email1 @ your. site '] This configuration is used to add stakeholder emails, so that after each build, CC. RB reads the configuration and sends the mail to the recipients of the email list;
2) project. email_notifier.from = 'email2 @ Your. site'. This configuration specifies the sender in the notify mail. You can configure different mail for different projects.
3) project. rake_task = 'custom'. It seems that this configuration only needs to be configured when you use the rake tool. If you use tools such as Ant and make, this configuration also needs to retain the original commented state;
4) project. build_command = 'build _ my_app.sh '. This configuration gives you the opportunity to customize the build script. In this way, you can change the CC. RB is integrated with ant, make, and other tools. For example, project. build_command = 'make '. Pay attention to CC. the working dir for RB to execute build_command is $ (home )/. under cruise/projects/test_proj/work, if your build_my_app.sh is not placed under work, it is in $ (home )/. under cruise/projects/test_proj, You need to configure it as project. build_command = '.. /build_my_app.sh '; project. build_command and project. rake_task cannot be used together.
5) project. scheduler. polling_interval = 5. minutes, CC. RB regularly checks whether SVN has new revision. This configuration is used to specify the detection cycle. If you do not configure it, the default value is 30 s.
If all the above configurations are complete, you can start cc. RB now. Start method: Go to the cruisecontrolrb-1.3.0 directory and execute "Cruise start-P port ". Cc. RB will launch a lightweight Web server-webrick. It is very convenient for me who is not familiar with Web server. I just need to tell the CC. RB port. Cc. after Rb is started, you can enter http: // ip: Port, CC in the browser. the simple RB page is displayed. You will see the project test_proj you just created on the page, and click "build now" in the upper right corner, you started a build process. Whether it succeeds or fails, you should receive a mail. For details about this build, click the link in mail. If the build fails, you can view the detailed log of this build in the "build log" on the page to help you analyze the cause of the failure.
How does cc. RB determine whether the build process succeeds or fails? Taking the configuration of Project. build_command = 'xx' as an example, in fact, CC. RB determines whether the build process is successful by judging the return value of the builder xx. If the builder XX returns 0, the build is successful; otherwise, the build fails. Let's test it: Write a small program under $ (home)/. Cruise/projects/test_proj/work:
/* Test. C */
Int main (){
Exit (0 );
}
Gcc-O test. c
Configure project. build_command = 'test', click "build now", and receive the mail, prompting you to build success. If you change exit (0) to exit (1 ), then a failed mail will be sent to your mailbox.
C/C ++ does not have a good unit test tool. Generally, C/C ++ unit test tools compile unit test cases into an executable file and then execute them, to determine whether the request passes. So far, have you thought of how to integrate unit tests of C/C ++ with CC. RB? Yes, we can use a script or simply write a unit test framework by ourselves, and tell cc. RB whether the newly submitted code has passed the unit test through the program return value.
The above is the content recorded when you first experience cc. RB. In fact, CC. Rb is so simple!