jenkins自动化

one of the reasons our society can function is our ability to communicate in a standard? well formed and universally %albeit with local + cultural variations% understandable way) this requires that not only symbols but also their usage be agreed? whether implicitly or explicitly? by both the transmitter + the receiver of information))if such uniformity were ~present? , one could write as it pleased him x her and if documents were interpreted in different ways by different individuals? we would live in a chaotic state of communication + our collective intellectual achievements ~~impossible=

我们的社会能够运作的原因之一是我们有能力进行标准沟通吗? 格式良好,并且普遍具有本地文化差异的理解方式),这不仅要求符号而且还应同意使用它们? 隐式还是显式? 由信息的发送者+接收者))如果存在这种一致性? ,是否可以随心所欲地写信给他和她,以及文件是否由不同的人以不同的方式解释? 我们将生活在混乱的沟通状态中+我们的集体智力成就~~不可能=

The paragraph is hard to understand because some punctuation has been changed and formatting conventions altered: use of the plus sign to represent the conjunction ‘and’, question mark instead of a comma, and double closing parenthesis where you would expect a period. Had our accepted writing rules been used, the paragraph would instead look like this:

该段很难理解,因为某些标点符号已更改,格式约定也有所更改:使用加号表示连词“和”,问号而不是逗号,并在双引号中加上句号。 如果使用了我们接受的书写规则,则该段落应如下所示:

One of the reasons our society can function is our ability to communicate in a standard, well formed and universally – albeit with local and cultural variations – understandable way. This requires that not only symbols but also their usage be agreed, whether implicitly or explicitly, by both the transmitter and the receiver of information.

我们的社会能够运作的原因之一是我们能够以一种易于理解的方式,以标准的,结构良好的和普遍的方式进行交流的能力(尽管存在本地和文化差异)。 这要求信息的发送者和接收者不仅隐式地或显式地不仅要符号而且要同意它们的用法。

If such uniformity were not present, if one could write as it pleased him or her and if documents were interpreted in different ways by different individuals, we would live in a chaotic state of communication and our collective intellectual achievements would be impossible.

如果没有这种统一性,如果一个人可以随心所欲地写东西,而且如果文件是由不同的人以不同的方式来解释的话,我们将生活在一个混乱的交流状态中,我们的集体知识成就将是不可能的。

The need for standards in technical communication, including symbols in drawings, has been long realized and the International Organization for Standardization (ISO) and its brethren in all industrialized nations exist to respond to such need. In the arts, things are not so exacting, yet there are some rules called ‘styles’. Architects and poets are often bound to a bunch of them. Writers of prose and painters have much more freedom but still obey to some rules.

对技术交流中的标准(包括附图中的符号)的需求已经很早就实现了,并且国际标准化组织(ISO)及其在所有工业化国家的兄弟都对这种需求做出了回应。 在艺术中​​,事情并不那么严格,但是有一些规则被称为“风格”。 建筑师和诗人常常被束缚在其中。 散文和画家的作家有更多的自由,但仍然服从某些规则。

One particular type of artistic writer, like you and me, is the code writer, the software developer. In our trade things are not always clear. Like medicine, computer programming is part science, part technique, and part art. We have to abide to some rules so that the dumb machines we write for can understand our desires. But otherwise, we’re quite free to write what we want the way we want.

像您和我一样,一种特殊类型的艺术作家是代码作者,即软件开发人员。 在我们的贸易中,事情并不总是很清楚。 像医学一样,计算机编程是科学,技术和艺术的一部分。 我们必须遵守一些规则,以便为我们编写的愚蠢机器能够理解我们的愿望。 但是除此之外,我们可以自由地以自己想要的方式来编写我们想要的东西。

Or, are we?

还是我们?

It’s all very well and good to follow one’s own private programming rules (using camelCase variable names for example) when individually writing isolated applications like a small budget website. However, collaborative work requires an agreement of common rules or you know what happens – and if by any chance you don’t, I suggest you take a look at the tale I told in my article Continuous Integration (with Jenkins).

在单独编写像小型预算网站这样的独立应用程序时,遵循自己的私有编程规则(例如,使用camelCase变量名)非常好。 但是,协作工作需要达成通用规则的共识,否则您就会知道会发生什么。如果有任何机会,您最好看看我在我的《 持续集成(与Jenkins)》一文中讲述的故事。

Nevertheless, if CI can cure the maladies typical of group development, it is powerless to deal with potential problems in the integration of different applications where wildly different styles may make understanding “source” code difficult (except, maybe, to the original developer) or even lead to name collisions. To address that need, a group of developers have proposed a standard for use with PHP, known as PSR-X, as described in Hari K T’s article PSR-1 and PSR-2 to be Approved as Standards.

但是,如果CI可以解决小组开发中典型的弊病,则无法解决集成不同应用程序中的潜在问题,在这些应用程序中,千差万别的样式可能会使理解“源”代码变得困难(也许对原始开发人员而言除外),或者甚至导致名字冲突。 为了满足这一需求,一组开发人员提出了与PHP一起使用的称为PSR-X的标准,如Hari K T的文章PSR-1和PSR-2被批准为标准中所述 。

Though it’s still early to guarantee that the PSRs will be widely adopted as the de facto standard for writing serious PHP applications, it is interesting to note that a code sniffer and fixer that looks for code deviations was developed by nobody less than Fabien Potencier, the creator of the Symfony framework. (Et bien, ils ne sont pas fous, ces français!) In the rest of the article we shall find out what his PHP-CS-Fixer does and how can it be integrated with a CI tool like Jenkins.

尽管现在要保证将PSR广泛用作编写严肃PHP应用程序的事实上的标准还为时过早,但有趣的是要注意,寻找代码偏差的代码嗅探器和修复程序由Fabien Potencier, Symfony框架的创建者。 (Et bien,其他人,还有法语!)在本文的其余部分,我们将了解他PHP-CS-Fixer的功能以及如何将其与诸如Jenkins的CI工具集成。

修复程序安装和基本用法 (Fixer Installation and Basic Usage)

According to its author, the PHP Coding Standards Fixer for PSR-1 and PSR-2 tool “fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents.” It does not solve all problems; and it does not claim to find every deviation from the standards, but, again quoting Fabien, it “comes with quite a few built-in fixers and finders, but everyone is more than welcome to contribute more of them.”

根据其作者的说法,用于PSR-1和PSR-2PHP编码标准修复程序“当您要遵循PSR-1和PSR-2文档中定义PHP编码标准时,可修复代码中的大多数问题。” 它不能解决所有问题。 它并没有声称发现所有偏离标准的地方,但是再次引用Fabien,它“带有许多内置的固定器和查找器,但是我们非常欢迎每个人都贡献更多的这些。”

Fixer installation is straightforward, or rather, none at all. All you have to do is to download the latest version of php-cs-fixer.phar from this Sensiolabs website (the company behind Symfony). Because the fixer is conveniently packed as a PHAR archive, all you have to do is to place it in a convenient folder, like the root of your development server, and run it from the command line:

修复程序安装非常简单,或者根本没有安装。 您所要做的就是从此Sensiolabs网站 (Symfony背后的公司)下载最新版本的php-cs-fixer.phar 。 由于该修复程序很方便地打包为PHAR归档文件,因此您要做的就是将其放在一个方便的文件夹中,例如开发服务器的根目录,然后从命令行运行它:

jajeronymo@desktop:~/www$ php php-cs-fixer.phar fix /path/to/dir

This will look for and fix PSR issues in all files in the directory (folder) at the end of /path/to/dir. If you want to check/fix just one file, instead use the path to the file:

这将在/path/to/dir末尾的目录(文件夹)中的所有文件中查找并修复PSR问题。 如果您只想检查/修复一个文件,请使用该文件的路径:

jajeronymo@desktop:~/www$ php php-cs-fixer.phar fix /path/to/file

In order to test the fixer, I wrote a “Hello World” script with three intentional violations of PSR: an opening tag without the ‘php’ designator. a tab used for indentation instead of four blank spaces, and a closing tag in a PHP-only script:

为了测试修复程序,我编写了一个“ Hello World”脚本,该脚本故意违反了PSR的三个方面:一个没有'php'标记的开始标记。 一个仅用于缩进的选项卡,而不是四个空格,以及一个纯PHP脚本中的结束标记:

<?
echo "Hello World";
?>

The file was saved in the same folder as fixer-test.php. Then I ran:

该文件与fixer-test.php保存在同一文件夹中。 然后我跑了:

jajeronymo@desktop:~/www$ php php-cs-fixer.phar fix fixer-test.php

The only response I received on the terminal was:

我在终端上收到的唯一回复是:

1) /home/prospero/www/fixer-test.php 

However, I checked fixer-test.php’s properties to find out that it had been modified at the time I ran the fixer. Opening the script, I noticed the fixer had added the ‘php’ designator after the opening tag, replaced the indentation tag with two blank spaces (uh oh, I expected four!), and did not remove the closing tag but rather added a linefeed after it – which complies with the standard’s requirement that a file must always end with an empty line feed. Out of curiosity I ran the fixer a second time and found out that the closing tag had been removed.

但是,我检查了fixer-test.php的属性,发现它在运行修复程序时已被修改。 打开脚本,我注意到修复程序在开始标记后添加了'php'标记,用两个空格替换了缩进标记(嗯,我希望有四个!),并且没有删除结束标记,而是添加了换行符之后-符合标准的要求,即文件必须始终以空换行结尾。 出于好奇,我第二次运行了修复程序,发现关闭标签已被删除。

At this point we have successfully gotten PHP-CS-Fixer to work, though only in basic mode. The script has a fair number of options that can be explored by the user. See the usage section of the app’s web page for more details.

至此,尽管仅在基本模式下,我们已经成功使PHP-CS-Fixer可以工作。 该脚本有很多可供用户探索的选项。 有关更多详细信息,请参见应用程序网页的用法部分。

詹金斯,请你帮我留意一下吗? (Jenkins, Will You Keep an Eye on This for Me, Please?)

As explained in my articles mentioned in the opening part of this one, Jenkins is a tool for automating a series of tasks, including testing, that are required for continuous integration. If you don’t have Jenkins, please refer to the Setting Up Jenkins section of Continuous Integration (with Jenkins), Part 2. Install and start Jenkins and come back here.

正如我在本文开头部分提到的文章中所解释的那样,Jenkins是一种工具,用于实现连续集成所需的一系列任务(包括测试)的自动化。 如果您没有Jenkins,请参阅第2部分“ 持续集成(与Jenkins)的设置Jenkins”部分。 安装并启动Jenkins,然后返回此处。

Run Jenkins’ war file and point your browser to http://localhost:8080. Click in “create new jobs” and then select “Build a free-style software project”. Give the job a name. (Since the time I was learning programming on a Burroughs mainframe in I call my test jobs “Trotter”. I wonder if any of my readers can guess why.)

运行Jenkins的war文件,然后将浏览器指向http://localhost:8080 。 单击“创建新作业”,然后选择“构建自由样式的软件项目”。 给工作起个名字。 (自从我在Burroughs大型机上学习编程的那段时间以来,我就把测试工作称为“ Trotter”。我想知道我的读者是否能猜出原因。)

Check “Build periodically” and write “*/5 * * * *” in the schedule box to run a test every five minutes. Now there are two ways we can follow. To run just PHP-CS-Fixer, we need to execute a shell command (or, in Windows, a batch file) and Jenkins will act as a surrogate to the cron job control. To integrate with a more elaborate set of tests and tasks, one can add an Ant script to it.

选中“定期构建”并在时间表框中输入“ * / 5 * * * *”以每五分钟运行一次测试。 现在,我们有两种方法可以遵循。 要仅运行PHP-CS-Fixer,我们需要执行一个shell命令(或者在Windows中为一个批处理文件),Jenkins将充当cron作业控件的替代者。 要与一组更复杂的测试和任务集成,可以向其中添加一个Ant脚本。

To follow the first option, select “Execute shell” in the “Add build step” drop-down button in the Build section. On the text box put the command to execute the fixer using the absolute path to files or folders. For my test script that is:

要遵循第一个选项,请在“构建”部分的“添加构建步骤”下拉按钮中选择“执行外壳”。 在文本框中,输入命令以使用文件或文件夹的绝对路径执行修复程序。 对于我的测试脚本是:

php /home/jajeronymo/www/php-cs-fixer.phar fix /home/jajeronymo/www/fixer-test.php

Save the configuration. Until stopped or shut-down, Jenkins will run the fixer on file fixer-test.php every five minutes. To see the fixer in action, create some deviations in the test file, like suppressing the ‘php’ from the opening tag, and wait until Jenkins runs the fixer. Then open the test file to check the corrections made.

保存配置。 在停止或关闭之前,Jenkins将每五分钟在文件fixer-test.php上运行该修复程序。 要查看修复程序的运行情况,请在测试文件中创建一些偏差,例如从开始标记中取消“ php”,然后等到詹金斯运行修复程序。 然后打开测试文件以检查所做的更正。

If no changes occur or if the builds list in Jenkins dashboard shows red balls, an error is occurring. Please click on the time of the job to open its record and then on the link “Console output” to see what’s, or what’s not, going on.

如果未发生任何变化,或者Jenkins仪表板中的构建列表显示红球,则发生错误。 请单击工作时间以打开其记录,然后单击“控制台输出”链接以查看发生了什么或没有发生什么。

Finally, to run the fixer from an Ant script, add this to its existing contents:

最后,要从Ant脚本运行修复程序,请将其添加到其现有内容中:

<project name="user">
...
<exec executable="php" failonerror="true">
<arg line="/home/prospero/www/php-cs-fixer.phar fix /home/prospero/www/fixer-test.php" />
</exec>
...
</project>

摘要 (Summary)

The adoption of coding standards is essential to reduce development costs of complex web applications as well as to guarantee that investment will be permanent and not dependent on the original programming team. The PSR proposition can be a way toward that and its ease of use with CI platforms like Jenkins is made possible by tools like PHP-CS-Fixer.

编码标准的采用对于降低复杂Web应用程序的开发成本以及确保投资将是永久性的且不依赖于原始编程团队至关重要。 PSR提议可能是实现这一目标的一种方法,并且通过PHP-CS-Fixer之类的工具使其易于在Jenkins等CI平台上使用。

Image via Fotolia

图片来自Fotolia

翻译自: https://www.sitepoint.com/automate-psr-compliance-through-jenkins/

jenkins自动化

jenkins自动化_通过Jenkins自动化PSR合规性相关推荐

  1. 会计凭证自动化_贵公司会计自动化前后的生活

    会计凭证自动化 The manual work of the accountant went into oblivion. Today everyone makes machines, but, of ...

  2. 数据科学自动化_数据科学会自动化吗?

    数据科学自动化 意见 (Opinion) 目录 (Table of Contents) Introduction介绍 Automation of Data Science数据科学自动化 Pros an ...

  3. docker jenkins 公钥_搭建 Jenkins 与 GitLab 的持续集成环境

    一.生成新的公私钥 ssh-keygen -t rsa -b 4096 -C "11776174@qq.com" Generating public/private rsa key ...

  4. 网格搜索自动化_使用GridGuide自动化您的网格设计过程

    任何网站设计的第一步都是挑选一个网格. 这通常定义页面的最大宽度,以及将用于划分布局的内部列和装订线的数量. 您可以尝试构建自己的工具,但最好的工具是GridGuide . 这是一个完全免费的Web应 ...

  5. python 仿真 电力系统自动化_解析电力系统自动化仿真技术的现状和展望

    龙源期刊网 http://www.doczj.com/doc/e72fa5948bd63186bdebbc39.html 解析电力系统自动化仿真技术的现状和展望作者:陈芳

  6. 混合的app自动化_混合网络自动化

    混合的app自动化 When the captcha pops, the algo stops 当验证码弹出时,算法停止 In our prior article Web Automation we ...

  7. APP自动化_操作微信小程序/H5页面实现自动化_多终端并行

    APP自动化_混合App自动化理论相关 原理:本质是混合app,应该用切入webview的方法去自动化web页面. 现状:目前由于技术原因无法切到webview中做自动化. 方案:采用原生app自动方 ...

  8. jenkins教程菜鸟_使用 jenkins 自动化部署应用(写给新手的)

    jenkins官网: https://jenkins.io/ jenkins.war 的下载地址 链接:https://pan.baidu.com/s/1fhlnxpkQwwkIzurGdrqEiA ...

  9. git自动部署代码到服务器windows,Jenkins-在windows上配置自动化部署(Jenkins+Gitlab+IIS)...

    Jenkins-在windows上配置自动化部署(Jenkins+Gitlab+IIS) web部署样例 windows服务部署样例 系统备份 在服务器上创建后缀名为.ps1的文件,例:BackUpD ...

最新文章

  1. 让织梦内容页arclist标签的当前文章标题加亮显示
  2. 阿里云 mysql 无缘无故挂掉
  3. Lexus Extroic OpenCart 2.X 自适应主题模板 ABC-0648-03
  4. 中国智能语音产业发展白皮书十大观点发布!科大讯飞市占率国内第一
  5. 国内三款主流海淘产品APP竞品分析
  6. App设计灵感之十二组精美的插画引导页设计案例
  7. CSS中的position
  8. VS2015配置内核WDK7600环境,32位下.
  9. 为什么Python中整型不会溢出
  10. JS数据结构与算法——选择排序(把小的数字依次往前放)
  11. 研究生量子计算机专业,量子计算机研究.PDF
  12. vue 拷贝 数组_vue源码中值得学习的方法
  13. Java第二节课总结
  14. springboot+springcloudgateway+nacos+sleuth+zipkin+mysql
  15. chrome浏览器无法登录印象笔记
  16. 图论法求解经典面试题:NxN匹马,N个赛道,求最快前M匹马,至少需要几次比赛?
  17. Linux命令调整显存,nVidia多显卡多GPU在Linux下的超频设置
  18. 2014湖南农业大学ACM校赛
  19. 「 每日一练,快乐水题 」728. 自除数
  20. Flink process 和 apply 简单案例

热门文章

  1. JDK配置(Win10, jdk1.8.0_181)
  2. Android 权限被拒绝,跳转至权限设置界面
  3. h5 实现公众号登录
  4. 如何建设数据指标体系?
  5. 计算机二级乙等题目,2015年全国计算机等级考试一级WPS练习题及答案
  6. 安防三国,三分天下。
  7. 彻底删除MySQL57服务
  8. 实践一年之久,vivo 如何基于 APISIX 进行业务基础架构的演进
  9. 计算机工程与网络学术会议,2015第五届计算机工程与网络国际学术会议
  10. Vultr IP及SSH 故障排除信息