Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Problem managing npm versions with CICD pipeline

we have a cloud build pipeline to build and upload a Node.js package to Artifact Registry. it works but if we re-run it, we get this error:

Step #4: npm ERR! 400 Bad Request - PUT https://us-central1-npm.pkg.dev/project/repo/package - Requested version xxx already exists.

we understand what the error message is saying. the problem is that it is a nuisance. developers often forget to manually bump up the version number, then check it to source control before kicking off the cloud build. And we have tens of Node.js packages that need to be build. the manual process is not scalable.

What can we do to get around this nuisance? 

Things we have thought of: run a script as part of cloud build steps that will bump up the version number in package.json before starting the build. the problem we face here is that this updated version number needs to be committed back into source control, otherwise next time we run the job we will get back a previous version

things are further complicated by the fact that we have to maintain source code in two repositories: google source control repos and our company's private bitbucket server. we were not able to connect to the company's bitbucket server with GCP. so first, we don't know know to commit the changes back to google cloud source repo and even if we did, the changes would not reflect in bitbucket which is what the developers use to pull code to their local machine.

what is the best design here? can anybody help? thanks

0 0 351
0 REPLIES 0