我的Jenkins是否从我的SCM构建结账?

我的Jenkins是否从我的SCM构建结账?

问题描述:

Trying to understand this CI thing so I've downloaded Jenkins in my production server...

1. Is Jenkins (or any other CI system) installed in the production server or I should have a separate server for Jenkins builds? If Jenkins is in another server, how can I integrate the builds as my running production code? Or this CI thing does have nothing to do with deploys?

Then I created a SSH key at /var/lib/jenkins/.ssh added to my Bitbucket (Git) repository as Deployment key...

2. Is this the correct approach?

...And set the repository URL git@bitbucket.org:... with jenkins user credentials in the Git plugin at project settings. So far so good, my build checkout the project to the Jenkins workspace, then I noticed that every build it run is a checkout and for every checkout, as a Composer powered project, my vendors/ directory isn't there, so I don't have the autoload.php file that phpunit.xml uses as bootstrap to load the classes and run the tests. So besides phpunit as one of the build shell commands I've added composer init.

3. Is this right? Should I run composer init on every build?

The main question maybe is: are my builds constructed from greenfield space? Should I checkout and run composer install and whatever scripts my project must take to be running every time (every build)?

Thanks!

试图理解这个 CI 因此我在生产服务器中下载了 Jenkins ... p>

1。 Jenkins(或任何其他CI系统)是否安装在生产服务器中,或者我应该为Jenkins构建提供单独的服务器? strong> 如果Jenkins位于另一台服务器中,我如何将构建集成为我的运行 生产代码? 或者这个CI事件与部署无关? em> p>

然后我在/var/lib/jenkins/.ssh创建了一个SSH密钥,添加到我的 Bitbucket Git ) 存储库作为部署密钥... p>

2。 这是正确的方法吗? strong> p>

...并使用 jenkins设置存储库URL git@bitbucket.org:... code> code>项目设置中Git插件中的用户凭据。 太好了,我的构建检查项目到Jenkins工作区,然后我注意到它运行的每个构建都是一个结账,每次结账时都是作曲家支持的项目,我的 vendors / code>目录不存在,所以我没有 autoload.php code>文件, phpunit.xml code>用作引导来加载类并运行测试。 所以除了 phpunit code>作为构建shell命令之一,我添加了 composer init code>。 p>

3。 这是正确的吗? 我应该在每次构建时运行 composer init code>吗? strong> p>

主要问题可能是:我的构建是否是从绿地空间构建的? 我应该签出并运行 composer install code>以及我的项目每次(每次构建)必须运行的脚本吗? p>

谢谢! p> DIV>

  1. Is Jenkins (or any other CI system) installed in the production server or I should have a separate server for Jenkins builds? If Jenkins is in another server, how can I integrate the builds as my running production code? Or this CI thing does have nothing to do with deploys?

Then I created a SSH key at /var/lib/jenkins/.ssh added to my Bitbucket >(Git) repository as Deployment key...

  1. Is this the correct approach?

That's correct. I have a bunch of servers configured this way. In the near future I want investigate if it would be possible to use the SSH Credentials Plugin to store my credentials there, so that I don't have to take care with the file system permissions for that key.

  1. Is this right? Should I run composer init on every build?

The main question maybe is: are my builds constructed from greenfield space? Should I checkout and run composer install and whatever scripts my project must take to be running every time (every build)?

It depends on your requirements. You can have several builds, or parametrize you build to support different behaviours. For instance, I have Laravel builds that depending on the environment parameter, they might do further testing with Selenium, or simply run phpunit.

I usually have two projects in Jenkins for each PHP application. One that checks out the code from git, clean any left-over of other builds in the workspace, and invokes Laravel's Envoy for building the project. What it basically does, is call composer install with some extra parameters, and call the migration and database seed routines to prepare the application for testing.

The other job is triggered when I promote (with Jenkins Promoted Builds Plugin) a build, and it copies (with the Copy Artifacts Plugin) the workspace created during build and already tested, and deploys it via scp to a folder in a QA server. It then updates some symbolic links, and finally it's ready to test.

With time and more requirements from developers and other teams, you'll get familiar with many other plug-ins, like the Email-ext Plug-in, to send custom notifications and include further information about the build.

Best practices would dictate a separate VM for Jenkins, just to keep it apart from other environments that it might deploy TO.

Jenkins can take down other services using scripts, so taking down the same tomcat running Jenkins that you are deploying a project to would be... inconvenient.

I fall into the camp that favors multiple Jenkins jobs that are chained together. One job builds. Another tests. and a third deploys. That way you know exactly which job is problematic. You can also look at job run times and get a better picture of what is taking so long (is it deploy? is it the unit tests?) and troubleshoot the problems from a higher POV.

I have a Jenkins Best Practices presentation I gave at the Boise Code Camp 2015 available here: http://lanyrd.com/2015/boise-code-camp/sdkggb/