用git做持续集成

来源:互联网 发布:mac用itunes制作铃声 编辑:程序博客网 时间:2024/04/28 13:36

先mark一下,准备研究这个。慢慢写。。。。。


一般使用git做CI的基本的work flow是这样的:

1)有可供CI Server使用的repo;

2) 开发push特定的branch到report,通常是master

3)CI Server自动检测到changes然后执行build

4)执行对应的单元测试

5) CI Server给reporsitory打tag并release



github 和git的关系:

git是版本控制系统,和CVS等是一个概念,而github是基于git的网站,用于给用户提供git 服务

关于git和github之间的区别:

   1.What is the difference between Git and GitHub?

      Git is a version control system; think of it as a series of snapshots (commits) of your code. You see a path of these snapshots, in which order they where created. You can make branches to experiment and come back to snapshots you took.
      GitHub, is a web-page on which you can publish your Git repositories and collaborate with other people.
   2.  Is Git saving every repository locally (in the user's machine) and in GitHub?
      No, it's only local. You can decide to push (publish) some branches on GitHub.
   3. Can you use Git without GitHub? If yes, what would be the benefit for using GitHub?

      Yes, Git runs local if you don't use GitHub. An alternative to using GitHub could be running Git on files hosted on Dropbox, but GitHub is a more streamlined service as it was made especially for Git.
   4
          How does Git compare to a backup system such as Time Machine?

      It's a different thing, Git lets you track changes and your development process. If you use Git with GitHub, it becomes effectively a backup. However usually you would not push all the time to GitHub, at which point you do not have a full backup if things go wrong. I use git in a folder that is synchronized with Dropbox.
   5Is this a manual process, in other words if you don't commit you won't have a new version of the changes made?

      Yes, committing and pushing are both manual.

下面讲述安装:

github的安装:

windows环境下载github for windows:

https://windows.github.com/

安装比较简单,一路next之后需要一个github的账号,完成注册即可,注册在网站https://github.com/

你可以选择安装git和也可以选择不安装git,直接用github的GUI

安装完成之后可以创建一个repository然后publish到github上去。

比如我自己创建了一个,在github网站上的链接图片是这样的

安装完成之后还需要安装git

2) 安装Jenkins for windows:

直接在jenkins的官网上下载http://jenkins-ci.org/。 可以下载war包或者下载

Or native package
Windows
一路next安装完成

更多使用jenkins的信息可以参考:https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins


3)安装git plugin, 通常情况下git plugin可以直接在jenkins的management plugin可以直接安装,但是由于我这边环境有防火墙看不到plugin的东西

所以只能直接在jenkins的官网上下载plugin安装

需要一并安装的plugin包括:

https://wiki.jenkins-ci.org/display/JENKINS/SCM+API+Plugin

https://wiki.jenkins-ci.org/display/JENKINS/Git+Client+Plugin

https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin


安装方法很简单:

Manage Plugins-->advanced-->upload hpi 即可。 建议如果没有防火墙的话可以直接安装 这样可以解决dependency的问题,不然还得自己一个下载

Preparation scm-api SuccessPreparation ssh-credentials ssh-credentials plugin is already installed. Jenkins needs to be restarted for the update to take effectPreparation credentials credentials plugin is already installed. Jenkins needs to be restarted for the update to take effectPreparation git-client SuccessPreparation git Success

4)安装github plugin,安装方法同上,以及相关依赖。

https://wiki.jenkins-ci.org/display/JENKINS/Multiple+SCMs+Plugin

https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin

https://wiki.jenkins-ci.org/display/JENKINS/GitHub+API+Plugin


5)配置jenkins:配置jenkins的系统设置的git以及jdk的环境。


7)建立build的project并进行相关设置。

主要需要设置scm的git的reporsoty路径以及build的triiger





8)checkin 一个文件到github并同步,然后你能看到最新的变化






0 0
原创粉丝点击