Detached HEAD in Continuous Integration Publish
See original GitHub issueExpected Behavior
Using a few flags with lerna publish
in order to brute force publishing of all packages in CI without confirmation prompts.
lerna publish --cd-version $VERSION --yes --force-publish=*
Current Behavior
I’m pretty sure this isn’t a bug, but most likely something to do with how Travis CI works with git. I’ve added a new remote with GitHub auth token, but am unsure where/what in the Lerna code is failing
0.78s$ if [ $TRAVIS_BRANCH = "master" ]; then yarn publish-ci; else gulp build; fi
yarn publish-ci v0.24.6
$ VERSION=${MODULE_VERSION:-patch}; echo "publishing $VERSION"; lerna publish --cd-version $VERSION --yes --force-publish=*
publishing minor
lerna info version 2.0.0-rc.4
lerna info current version 1.0.4
lerna info Checking for updated packages...
lerna info Comparing with tag v1.0.2
Changes:
- @h1/boiler-config-eslint: 1.0.4 => 1.1.0
- @h1/boiler-config: 1.0.4 => 1.1.0
- @h1/boiler-core: 1.0.4 => 1.1.0
- @h1/boiler-task-eslint: 1.0.4 => 1.1.0
- @h1/boiler-utils: 1.0.4 => 1.1.0
lerna info auto-confirmed
lerna ERR! execute Error: Detached git HEAD, please checkout a branch to publish changes.
lerna ERR! execute at PublishCommand.execute (/home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/commands/PublishCommand.js:235:17)
lerna ERR! execute at PublishCommand._attempt (/home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/Command.js:265:21)
lerna ERR! execute at /home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/Command.js:252:15
lerna ERR! execute at /home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/Command.js:274:13
lerna ERR! execute at PublishCommand.confirmVersions (/home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/commands/PublishCommand.js:471:9)
lerna ERR! execute at /home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/commands/PublishCommand.js:227:16
lerna ERR! execute at PublishCommand.getVersionsForUpdates (/home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/commands/PublishCommand.js:319:16)
lerna ERR! execute at PublishCommand.initialize (/home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/commands/PublishCommand.js:208:12)
lerna ERR! execute at PublishCommand._attempt (/home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/Command.js:265:21)
lerna ERR! execute at PublishCommand.runCommand (/home/travis/build/SystemsSoftware/build-boiler/node_modules/lerna/lib/Command.js:251:12)
Possible Solution
For now I’m passing the additional flag of --skip-git
which obviously fixes the issue
Steps to Reproduce (for bugs)
Right now this is in GitHub Enterprise and Running on Travis Enterprise but I can create a small open source example if necessary.
// lerna.json
{
"lerna": "2.0.0-rc.4",
"version": "1.0.4",
"npmClient": "yarn"
}
| yarn --version
| 0.23.4 |
| node --version
| 7.10.0 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Detached head in gitlab ci pipeline - how to push correctly
I think the pipeline creates a detached repository by initial fetching. So the question is how to handle my push in a correct...
Read more >Git Detached Head: What Is It & How to Recover
Git detached head might be a weird error message, but don't despair. Learn what this means and how to fix it!
Read more >Git Detached Head: What This Means and How to Recover
As you've seen in this post, a detached HEAD doesn't mean something is wrong with your repo. Detached HEAD is just a less...
Read more >Recovering from the Git detached HEAD state - CircleCI
In Git, HEAD refers to the currently checked-out branch's latest commit. However, in a detached HEAD state, the HEAD does not point to...
Read more >What is the exact use of DETACHED HEAD state in Git?
If you switch to detached mode (e.g. by git checkout --detach or checking out a specific commit, tag or remote branch), HEAD is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you are on jenkins and have this problem you can add the local branch plugin to your checkout SCM:
extensions: [[$class: 'LocalBranch', localBranch: '**']]
This will tell jenkins git to use a local branch, avoiding the detached head state.Wouldn’t
git checkout master
beforeyarn publish-ci
be sufficient?