rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] 'publish' exits with error code when remote branch has changes - but packages and tags are pushed as expected

Open crhaglun opened this issue 5 years ago • 4 comments

Is this a feature or a bug?

  • [ ] Feature
  • [x] Bug

Please describe the actual behavior.

We have a dedicated build pipeline for "rush publish", scheduled weekly + occasional manual runs.

Fairly often this pipeline fails when pushing git tags because of updates on the target branch happening while "rush publish" is running.

The git tags are actually pushed, but the update of HEAD fails causing the whole operation to fail;

Invoking "rush publish --publish --include-all -b master --registry https://instance.pkgs.visualstudio.com/_packaging/project/npm/registry/ -n ***"
---------------------------------------------------------------------------------------------------------------------------------------------------

Rush Multi-Project Build Tool 5.23.2 - https://rushjs.io
Node.js version is 10.15.3 (LTS)

Starting "rush publish"

Validating package manager shrinkwrap file.

Rush publish starts with includeAll and version policy undefined

* EXECUTING: D:\a\1\s\common\temp\pnpm-local\node_modules\.bin\pnpm publish --//instance.pkgs.visualstudio.com/_packaging/project/npm/registry/:_authToken=<<SECRET>> (packages\components\component)

<npm output omitted>

* EXECUTING: git tag -a @namespace/component_v1.2.79 -m @namespace/component_v1.2.79 

* EXECUTING: git push origin HEAD:master --follow-tags --verbose --no-verify 
POST git-receive-pack (245289 bytes)
Pushing to https://instance.visualstudio.com/Project/_git/repo
To https://instance.visualstudio.com/Project/_git/repo
 * [new tag]             @namespace/component_v1.2.79 -> @namespace/component_v1.2.79
 ! [rejected]            HEAD -> master (fetch first)
error: failed to push some refs to 'https://instance.visualstudio.com/Project/_git/repo'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

ERROR: The command failed with exit code 1

If the issue is a bug, how can we reproduce it? Please provide detailed steps and include a GitHub branch if applicable. Your issue will get resolved faster if you can make it easy to investigate.

Run "rush publish" on a commit that's not the most recent commit on a branch (like master~1)

A very similar problem was reported on semantic-release: https://github.com/semantic-release/semantic-release/issues/993 Fixed in that project by omitting 'HEAD:branchname' from the "git push" command. Is that a plausible fix here as well?

What is the expected behavior?

Since this is not a functional problem -- NPM packages are pushed and git tags are indeed updated correctly -- it's a bit unexpected that the command exits with an error code.

If this is a bug, please provide the tool version, Node.js version, and OS.

  • Tool: Rush
  • Tool Version: 5.23.2
  • Node Version: 10.15.3
    • Is this a LTS version? Yes
    • Have you tested on a LTS version? Yes
  • OS: Windows

crhaglun avatar Jul 23 '20 21:07 crhaglun