How to increase version of NPM package with AWS CodePipeline, CodeBuild and BitBucket repository

Viewed 209

I'm having the following flow:

developer adds a new feature for a library with version 1.0.0 => commits and pushes it to master => pipeline gets triggered => after the build phase has been complete => pipeline does a npm version patch ==> The version in package.json will be increased with +1 to 1.0.1) => therefor package.json version is now edited outside of git => This change needs to be committed back somehow to the master

I can commit this change back, by creating a BitBucket user and SSH keys and commit from AWS CodeBuild back, but then I create a loop because the pipeline will get triggered again on that commit.

What is the best way to do a version increase or version control with BitBucket, AWS CodePipeline and AWS CodeBuild?

Thanks.

1 Answers

I get around this by using the Author. I set mine to "AWS CodeBuild" so...

- AUTHOR=`git --no-pager show -s --format='%an' "$CODEBUILD_RESOLVED_SOURCE_VERSION"`
- echo "$AUTHOR"
- |
  if [ "$AUTHOR" != "AWS CodeBuild" ]; then
    <your code>
  fi
Related