Search code examples
node.jsgitcontinuous-deploymentgo-cdnpm-version

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


I am trying to update my git repo during the GoCD build. That means that because Go sees another change it triggers another build. 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.

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.


Solution

  • 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.

    Once this configuration is done in the CD/CI tool

    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 :)