Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - lerna ERR! ENOGIT Detached git HEAD within Gitlab CI #1157

Closed
jdalrymple opened this issue Apr 19, 2020 · 28 comments
Closed

Question - lerna ERR! ENOGIT Detached git HEAD within Gitlab CI #1157

jdalrymple opened this issue Apr 19, 2020 · 28 comments
Labels
bug Something isn't working

Comments

@jdalrymple
Copy link

jdalrymple commented Apr 19, 2020

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!

@jdalrymple jdalrymple added the bug Something isn't working label Apr 19, 2020
@jdalrymple
Copy link
Author

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

@hipstersmoothie
Copy link
Collaborator

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

@jdalrymple
Copy link
Author

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

@jdalrymple
Copy link
Author

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

@hipstersmoothie
Copy link
Collaborator

That error comes from auto

"Current commit is behind, skipping the release to avoid collisions."

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

@jdalrymple
Copy link
Author

jdalrymple commented Apr 20, 2020

🤦 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

@hipstersmoothie
Copy link
Collaborator

#1159

@jdalrymple
Copy link
Author

jdalrymple commented Apr 20, 2020

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

@hipstersmoothie
Copy link
Collaborator

Oh man 🤦 I must have deleted a -

#1160

@hipstersmoothie
Copy link
Collaborator

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

@jdalrymple
Copy link
Author

Another problem fixed butttt hehe Any other suggestions?

@hipstersmoothie
Copy link
Collaborator

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

@jdalrymple
Copy link
Author

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

@jdalrymple
Copy link
Author

jdalrymple commented Apr 21, 2020

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

@jdalrymple
Copy link
Author

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 :/

@jdalrymple
Copy link
Author

jdalrymple commented Apr 21, 2020

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 :(

@hipstersmoothie
Copy link
Collaborator

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

@hipstersmoothie
Copy link
Collaborator

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

@jdalrymple
Copy link
Author

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.

@hipstersmoothie
Copy link
Collaborator

I think you need to up the output_limit https://docs.gitlab.com/runner/configuration/advanced-configuration.html

@jdalrymple
Copy link
Author

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?

@hipstersmoothie
Copy link
Collaborator

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

#1170

@hipstersmoothie
Copy link
Collaborator

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

@jdalrymple
Copy link
Author

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?

@hipstersmoothie
Copy link
Collaborator

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

#1170

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

@hipstersmoothie
Copy link
Collaborator

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

@jdalrymple
Copy link
Author

Ill check that! thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants