简体   繁体   English

Go.CD-在构建管道中更新git repo会触发另一个构建

[英]Go.CD - Updating git repo in build pipeline triggers another build

I am trying to update my git repo during the GoCD build. 我正在尝试在GoCD构建过程中更新我的git repo。 That means that because Go sees another change it triggers another build. 这意味着,由于Go看到了另一个更改,因此会触发另一个构建。 Is it possible to stop the re-triggering of the build? 是否可以停止重新触发构建?

Background: I am building and publishing npm packages and I want to automatically increase the prerelease version so I don't have to remember it. 背景:我正在构建和发布npm软件包,我想自动增加预发行版本,所以我不必记住它。

My pipeline looks essentially like this: 我的管道本质上是这样的:

npm version prerelease --no-git-tag-version
npm publish
git add package.json
git commit -m "Bump prerelease version"
git push origin

This will update the version in git if the publish succeeds but also triggers another build since Go is polling. 如果发布成功,这将更新git中的版本,但由于Go正在轮询,因此还会触发另一个构建。

Configure your CD/CI tool to build only when there is a commit to a specified branch or you can probably create a new branch called "pre-release" and configure CD/CI not to build when there is a commit. 将CD / CI工具配置为仅在提交到指定分支时才构建,或者您可以创建一个称为“预发行版”的新分支,并配置CD / CI在提交时不进行构建。

Once this configuration is done in the CD/CI tool 在CD / CI工具中完成此配置后

npm version prerelease --no-git-tag-version
npm publish

// fetching for other branches
git fetch

// Switching your branch 
git checkout pre-release

// Finally committing
git add -m "Your commit message"
git push -u origin pre-release

I hope this works out for you :) 我希望这对你有用:)

You can configure your stages in your pipeline to be triggered manually, for example, if you where setting up your pipelines as code, in your ${pipeline_name}.gocd.yaml . 您可以将管道中的阶段配置为手动触发,例如,如果将管道设置为代码,则在${pipeline_name}.gocd.yaml

  - deploy-to-next-stage:
      approval: manual            <-- You need this!
      jobs:
        deploy:
          tasks:
            ...

This may help as you could run an automated deploy to a development stage and then manually push successful builds to the next stage (pre-release perhaps). 这可能会有所帮助,因为您可以将自动部署运行到开发阶段,然后手动将成功的构建推送到下一个阶段(也许是预发行版)。 In this way, your builds that worked would not be effected by new builds being triggered by a push to your repo. 这样,您的有效构建不会因推送回购协议触发新构建而受影响。

Or you could put this on your first stage and your entire pipeline would not be triggered by the push to the repo, but instead by you heading into the GUI and triggering it yourself. 或者,您可以将其放在您的第一阶段,并且整个流程不会由推送到存储库触发,而是由您进入GUI并自行触发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM