我正在尝试为我的AngularJS项目设置CircleCI。 我想我已经做好了一切,但也存在一些问题。
当在功能分支(除了develop或master之外的任何东西)上推送提交时,我不想运行测试,并且绝对不会创建构建。 当为开发分支创建PR时,我希望测试此PR。 当合并PR时,或者如果在开发分支上进行其他直接提交,我希望创建和部署新的构建。问题是第一点,此时任何分支上的每次提交都会触发测试,而这根本就不需要。
我已经在circle.yml中尝试了这个但是这也阻止了PR对开发分支的测试似乎:
general: branches: only: - develop那么我怎样才能让Circle以我想要的方式行事? 或者我应该删除上面的配置并让它测试每个分支上的每个提交?
I am trying to set up CircleCI for my AngularJS project. I think I've done everything correctly, but there are some problems.
When a commit is pushed on a feature branch (anything except develop or master), I don't want to run test, and definitely not create a build. When a PR is created to the develop branch, I want this PR to be tested. When that PR is merged, or if other direct commits are made on the develop branch, I want a new build to be created & deployed.The problem is that first point, at this moment every commit on any branch will trigger a test, which is just not needed at all.
I've tried this in circle.yml but that also stops PR's to the develop branch from being tested it seems:
general: branches: only: - developSo how can I get Circle to behave in the way that I want? Or should I remove that config above and let it test every commit on every branch?
最满意答案
当在github中创建PR时,构成pull请求的提交仍然是其原始分支的一部分,而不是新分支,这意味着Circle将执行的任何测试将作为原始分支的一部分发生,您隐式将其列入黑名单。 合并的PR应该肯定会触发新的构建,因为合并的PR会导致新的提交SHA并触发CircleCI。 如果您希望在制作PR时运行测试,则需要更改circle.yml文件以允许您从中创建PR的分支。
获得此行为的另一种方法是在分支白名单中使用正则表达式匹配,以便以正常方式构建的任何分支名称将正常构建,然后从分支中获取所有拉取请求。 你只需要添加:
general: branches: only: - /pr-*/When a PR is made in github the commits that form the pull request still are a part of their original branches and not the new branch that means any tests that Circle will do will happen as part of the original branch which you are implicitly blacklisting. PRs that are merged should definitely trigger new builds since the merged PR results in a new commit SHA and triggers CircleCI. If you want tests to run when you make a PR you will need to change the circle.yml file to allow the branch you're making the PR from.
An alternate way to get this behavior would be to use regex matching in your branch whitelisting so that any branch name starting with something like pr- would be built normally and then make all of your pull requests from pr- branches. You would just need to add:
general: branches: only: - /pr-*/仅在开发分支上测试/构建提交 - CircleCI(Only test/build commits on the develop branch - CircleCI)我正在尝试为我的AngularJS项目设置CircleCI。 我想我已经做好了一切,但也存在一些问题。
当在功能分支(除了develop或master之外的任何东西)上推送提交时,我不想运行测试,并且绝对不会创建构建。 当为开发分支创建PR时,我希望测试此PR。 当合并PR时,或者如果在开发分支上进行其他直接提交,我希望创建和部署新的构建。问题是第一点,此时任何分支上的每次提交都会触发测试,而这根本就不需要。
我已经在circle.yml中尝试了这个但是这也阻止了PR对开发分支的测试似乎:
general: branches: only: - develop那么我怎样才能让Circle以我想要的方式行事? 或者我应该删除上面的配置并让它测试每个分支上的每个提交?
I am trying to set up CircleCI for my AngularJS project. I think I've done everything correctly, but there are some problems.
When a commit is pushed on a feature branch (anything except develop or master), I don't want to run test, and definitely not create a build. When a PR is created to the develop branch, I want this PR to be tested. When that PR is merged, or if other direct commits are made on the develop branch, I want a new build to be created & deployed.The problem is that first point, at this moment every commit on any branch will trigger a test, which is just not needed at all.
I've tried this in circle.yml but that also stops PR's to the develop branch from being tested it seems:
general: branches: only: - developSo how can I get Circle to behave in the way that I want? Or should I remove that config above and let it test every commit on every branch?
最满意答案
当在github中创建PR时,构成pull请求的提交仍然是其原始分支的一部分,而不是新分支,这意味着Circle将执行的任何测试将作为原始分支的一部分发生,您隐式将其列入黑名单。 合并的PR应该肯定会触发新的构建,因为合并的PR会导致新的提交SHA并触发CircleCI。 如果您希望在制作PR时运行测试,则需要更改circle.yml文件以允许您从中创建PR的分支。
获得此行为的另一种方法是在分支白名单中使用正则表达式匹配,以便以正常方式构建的任何分支名称将正常构建,然后从分支中获取所有拉取请求。 你只需要添加:
general: branches: only: - /pr-*/When a PR is made in github the commits that form the pull request still are a part of their original branches and not the new branch that means any tests that Circle will do will happen as part of the original branch which you are implicitly blacklisting. PRs that are merged should definitely trigger new builds since the merged PR results in a new commit SHA and triggers CircleCI. If you want tests to run when you make a PR you will need to change the circle.yml file to allow the branch you're making the PR from.
An alternate way to get this behavior would be to use regex matching in your branch whitelisting so that any branch name starting with something like pr- would be built normally and then make all of your pull requests from pr- branches. You would just need to add:
general: branches: only: - /pr-*/
发布评论