dongshan7708
2014-06-17 13:18 阅读 45

如何让Jenkins检测源代码中的受限单词并构建失败?

I have Jenkins CI.

Source code is PHP.

Jenkins grabs every 5 minutes source code from GIT.

How to configure to scan source code for resticted words:

  • sqlsrv_
  • mssql_

I need it to monitor another developers to avoid using deprecated functions in code.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dqqfuth6736 dqqfuth6736 2015-02-10 22:35

    I would suggest you define Sniffs (Custom based sniffs) and those can grab The mentioned words whenever they appear. You can then make your build fail or display error message accordingly.

    I have been able to create my own Sniffs after seeing how Sniffs are developed in:

    https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

    Hope this helps.

    点赞 评论 复制链接分享
  • dpc57092 dpc57092 2014-06-17 17:48

    What you need is a static code analysis tool for PHP. Then you need to configure Jenkins to launch that tool.

    There are tons available.

    Here is a question listing many static code analysis tools for PHP:
    Is there a static code analyzer [like Lint] for PHP files?

    Here is a question about linking one of those (PHP Code Sniffer) with Jenkins:
    Using Jenkins and Php Code Sniffer

    点赞 评论 复制链接分享

相关推荐