Auto: Question - lerna ERR! ENOGIT Detached git HEAD within Gitlab CI

Created on 19 Apr 2020  ·  28Comments  ·  Source: intuit/auto

Describe the bug

When running shipit, lerna errors out on the last step

This might be more related to lerna, as ive seen the errors reported a few times, but I was wondering if you guys had any suggestions since the lerna call is within auto?

EDIT: Testing locally returns different errors. Going to look into that further and followup!

bug

All 28 comments

Seems to work fine when ran locally, just not in the ci environment. hmm

First, IDK how well auto can possibly work with GitLab since we heavily use the GitHub API. Things like looking up the pull requests, making releases, and a whole host of other things won't work as expected.


As for the detached head issue: Most CI envs do not checkout your code in the same way. For auto to work it needs a relatively complete view of the git repo. Many CI envs try to be smart and not do a full checkout. Some will do a shallow clone (github actions). Some will pre-merge your branch and checkout a tmp branch (jenkins)

Looking at your logs it seems like GitLab does a relatively full checkout, but with detached head (you aren't on a branch). Try checking out master.

# See what branches are available
git branch -a

# Checkout master
git checkout master

That seemed to fix that error, but now it isnt releasing due to this :cry:

Did a quick search but i cant seem to figure out what causes that error message.

That error comes from auto

https://github.com/intuit/auto/blob/adf4e85590a75a9fd97945b4803f3535b8c45383/packages/core/src/auto.ts#L405

It might be swallowing another error though. I can add a log to print in this function if you need it

:facepalm: not sure how i missed that. Would it be possible to output that error if a verbose flag was set? I realized i couldn't do this locally because i cant create the error locally lol

Is it possible the -silent flag should be --silent ? or --quiet? Im not sure what the false and -silent flags are for.

https://gitlab.com/jdalrymple/gitbeaker/-/jobs/518962749#L1391

Oh man 🤦 I must have deleted a -

https://github.com/intuit/auto/pull/1160

Once this publishes it should be good https://github.com/intuit/auto/pull/1161/files

Another problem fixed butttt hehe Any other suggestions?

You seem to still be on an old canary "auto" version: v9.28.2-canary.1160.15021.0 and not the last released version

Oops! just fixed that. Still having bad luck :( Now with Error: Command failed: git merge-base --is-ancestor :cry:

Hmm reading over the logs again, is it possible its using the wrong remote url?

ℹ info Using remote: https://gitlab-ci-token:[MASKED]@gitlab.com/jdalrymple/gitbeaker.git

That could actually be the problem. The repo is hosted on github, but im using the gitlab ci for the pipeline. It looks like its inferring the remote to push to, but inferring incorrectly. Not sure how to change it though hmm

So i worked a way around this error by explicitly setting the remote url. Kinda of hacky, but it would work for now. Trying to fix a weird npm error now. So close :/

It worked!!! Had to explicitly set some things but yay! Thanks for the help!!

Quick question @hipstersmoothie , to avoid opening a new issue. Does auto handle creating new github releases? It created the tag and the release notes fine, but no github release :(

It is supposed to create the github release also. I'll look into what you've posted. We can dm on twitter if you want quicker responses too

Building on GitLab is probably the source of most of these problems. As you found with the remote CI services tend to make a bunch of different assumptions.

That said we might be able to improve the remote logic and detect when we are on gitlab CI.

Here is where you would change the code to figure out the remote https://github.com/intuit/auto/blob/master/packages/core/src/auto.ts#L556

It is supposed to create the github release also. I'll look into what you've posted. We can dm on twitter if you want quicker responses too

Ill make a another release in about 10 min so you can see what ends up happening, but the last release that was made i had to manually add the github release notes.

Looking into modifying that limit now. It looks like it errors when trying to get the git log AH, it is using a tag with the prefix 'v' but my lerna config excludes the prefix?

ℹ  info      Using 17.0.3 as previous release.
ℹ  info      Current "Latest Release" on Github: v17.0.3
ℹ  info      Getting commits from v17.0.3 to HEAD

shouldnt it be looking for commits from the tag to head, so in this case 17.0.3 to HEAD?

This is because auto defaults to v prefixes. I just opened a PR that will make auto respect the lerna config

https://github.com/intuit/auto/pull/1170

You could also just set noVersionPrefix in your auto config. but I think automating this is better

You could also just set noVersionPrefix in your auto config. but I think automating this is better

Would that be the better way to define that configuration? Probably eh?

The thing is you would also have to set the lerna config too

https://github.com/intuit/auto/pull/1170

I made it automatic so you should just need to upgrade auto

You might need to edit the last tag/release to not have the v prefix

Ill check that! thanks!

Was this page helpful?
0 / 5 - 0 ratings