Improve compatibility with CI/CD
See original GitHub issueContext
I have setup lerna
and I want to use lerna version
/ lerna publish
within my CI/CD pipeline in GitLab.
Expected Behavior
Get branch name correctly.
Current Behavior
In GitLab the branch is checked out as detached HEAD state so currentBranch
is always HEAD
which leads to issues:
Possible Solution
semantic-release is using env-ci
to determine the correct branch name: https://github.com/semantic-release/semantic-release/blob/7a939a897097a730f1579002ed641a583d3381c4/index.js#L6-L26
lerna
is using an own git
command instead of using env-ci
:
I am open to create another PR (beside my others https://github.com/lerna/lerna/issues/2333) for this solution.
A solution for this is to use env-ci
additionally, and use the git
command if the returned branch
is undefined
Apart from that I found another code where is-ci
is used:
Perhaps it should be considered to remove that package and also replace it with env-ci
. But there are breaking changes because both packages support different CI systems:
env-ci | is-ci (ci-info) |
---|---|
AWS CodeBuild | AWS CodeBuild |
AppVeyor | AppVeyor |
Azure Pipelines | |
Bamboo | Bambooby Atlassian |
Bitbucket | Bitbucket Pipelines |
Bitrise | Bitrise |
Buddy | Buddy |
Buildkite | Buildkite |
CircleCI | CircleCI |
Cirrus CI | Cirrus CI |
Codeship | Codeship |
Codefresh | |
Drone | Drone |
dsari | |
GitHub Actions | |
GitLab CI/CD | GitLab CI |
GoCD | |
Hudson | |
Jenkins | Jenkins CI |
Magnum CI | |
Netlify CI | |
Nevercode | |
Puppet | |
Sail CI | Sail CI |
Scrutinizer | |
Semaphore | Semaphore |
Shippable | Shippable |
Solano CI | |
Strider CD | |
TaskCluster | |
TeamCity | TeamCityby JetBrains |
Travis CI | Travis CI |
Visual Studio Team Services | |
Wercker |
Your Environment
Executable | Version |
---|---|
lerna --version |
3.18.4 |
npm --version |
6.4.1 |
yarn --version |
1.19.1 |
node --version |
v10.15.3 |
OS | Version |
---|---|
WSL | On Windows 10 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:10 (2 by maintainers)
Top GitHub Comments
Another issue on GitLab CI, that
postversion
lifecycle could not run:Has anyone experienced this before?
EDIT:
If your CI docker container runs as
root
user, you must add below line before all yourlerna version
orlerna publish
commands. Afterwards lifecycle events will work.Why this is needed for
root
users you can read here: What-does-unsafe-perm-in-npm-actually-doHow to push back to repository? I have found also a way to use
lerna
in GitLab CI. Please refer to this link or shortly said, use aGITLAB_TOKEN
variable:I think you may need to checkout to master branch.
I was able to get my CI to work and publish through Github Actions. Even if you’re not using Github Actions, maybe this could give you an idea of what to do. I added SSH-key and Github token which had write access to the repo.