Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab CI/CD and Nx affected:build

Tags:

gitlab

nrwl-nx

I'm having trouble getting Nx to build properly inside Gitlab's CI/CD tool.


> nx affected:build "--prod" "--base=remotes/origin/development~1" "--head=remotes/origin/development"

fatal: Not a valid object name remotes/origin/development~1 Command failed: git merge-base remotes/origin/development~1 remotes/origin/development fatal: Not a valid object name remotes/origin/development~1

I've tried different branches/commands such as just a plain: nx affected:build and I get the same error(just with a master branch indicated in the error message)

Anyone able to get the Nx monorepo working with Gitlab?

like image 645
davehyperion Avatar asked Sep 23 '19 18:09

davehyperion


People also ask

Can you have multiple pipelines in GitLab?

You can set up GitLab CI/CD across multiple projects, so that a pipeline in one project can trigger a pipeline in another project. You can visualize the entire pipeline in one place, including all cross-project interdependencies.

How does NX affect work?

How does it work? When you run nx affected --target=test , Nx looks at the files you changed in your PR, it will look at the nature of change (what exactly did you update in those files), and it uses this to figure the list of projects in the workspace that can be affected by this change.

Does GitLab support CI CD?

GitLab CI/CD is the part of GitLab that you use for all of the continuous methods (Continuous Integration, Delivery, and Deployment). With GitLab CI/CD, you can test, build, and publish your software with no third-party application or integration needed.

What is the purpose of GitLab CI?

GitLab CI (Continuous Integration) service is a part of GitLab that build and test the software whenever developer pushes code to application. GitLab CD (Continuous Deployment) is a software service that places the changes of every code in the production which results in every day deployment of production.


2 Answers

Had a similar problem. Running "git fetch" before the nx command fixed the issue.

like image 149
Jakub Daraz Avatar answered Oct 24 '22 03:10

Jakub Daraz


It no longer works after the newest update. If you have a main branch name other than master and want to utilize the '--all' option, there is a correct way to specify command-line arguments.

Try this

nx affected:build --all -- trunk HEAD

Notice the space after '--' before the branch name.

like image 1
Chandima Samarakoon Avatar answered Oct 24 '22 01:10

Chandima Samarakoon