`affected:build` failing in the pipeline
See original GitHub issueCurrent Behavior
The affected:build
is failing with the message:
fatal: Not a valid object name master
fatal: No such ref: 'master'
Although, the git fetch
is being called and branches are existing at the time the command is called
Successfully extracted cache
Executing "step_script" stage of the job script 00:02
$ git fetch
From https://some-path
* [new branch] add-linting-pipeline -> origin/add-linting-pipeline
* [new branch] master -> origin/master
* ...
$ NODE_ENV=production nx affected:build --parallel --maxParallel=8 --configuration=dev --deployUrl=./
> NX NOTE Affected criteria defaulted to --base=master --head=HEAD
fatal: Not a valid object name master
fatal: No such ref: 'master'
nx affected:build
Build applications and publishable libraries affected by changes
Run command using --base=[SHA1] (affected by the committed, uncommitted and
untracked changes):
--base Base of the current branch (usually master) [string]
or using --base=[SHA1] --head=[SHA2] (affected by the committed changes):
--base Base of the current branch (usually master) [string]
--head Latest commit of the current branch (usually HEAD) [string]
or using:
--files Change the way Nx is calculating the affected command by
providing directly changed files, list of files delimited by
commas [array]
--uncommitted Uncommitted changes [boolean]
--untracked Untracked changes [boolean]
Options:
--help Show help [boolean]
--version Show version number [boolean]
--parallel Parallelize the command (default: false) [boolean]
--maxParallel Max number of parallel processes. This flag is ignored if the
parallel option is set to `false`. (default: 3) [number]
--all All projects [boolean]
--exclude Exclude certain projects from being processed
[array] [default: []]
--runner This is the name of the tasks runner configured in nx.json
[string]
--skip-nx-cache Rerun the tasks even when the results are available in the
cache [boolean] [default: false]
--configuration This is the configuration to use when performing tasks on
projects [string]
--only-failed Isolate projects which previously failed
[boolean] [default: false]
--verbose Print additional error stack trace on failure
Error: Command failed: git merge-base --fork-point "master" "HEAD"
fatal: No such ref: 'master'
at checkExecSyncError (child_process.js:616:11)
at Object.execSync (child_process.js:652:15)
at getFilesUsingBaseAndHead (/builds/fo7brMD7/1/.../node_modules/@nrwl/workspace/src/command-line/shared.js:55:37)
at Object.parseFiles (/builds/fo7brMD7/1/.../node_modules/@nrwl/workspace/src/command-line/shared.js:31:20)
at projectsToRun (/builds/fo7brMD7/1/.../node_modules/@nrwl/workspace/src/command-line/affected.js:97:108)
at Object.<anonymous> (/builds/fo7brMD7/1/.../node_modules/@nrwl/workspace/src/command-line/affected.js:27:26)
at Generator.next (<anonymous>)
at fulfilled (/builds/fo7brMD7/1/.../node_modules/@nrwl/workspace/node_modules/tslib/tslib.js:114:62) {
status: 128,
signal: null,
output: [
null,
<Buffer >,
<Buffer 66 61 74 61 6c 3a 20 4e 6f 20 73 75 63 68 20 72 65 66 3a 20 27 6d 61 73 74 65 72 27 0a>
],
pid: 36,
stdout: <Buffer >,
stderr: <Buffer 66 61 74 61 6c 3a 20 4e 6f 20 73 75 63 68 20 72 65 66 3a 20 27 6d 61 73 74 65 72 27 0a>
}
Cleaning up file based variables 00:00
ERROR: Job failed: command terminated with exit code 1
Environment
Node : 14.15.4 OS : win32 x64 yarn : 2.4.2
nx : 11.1.1 @nrwl/angular : Not Found @nrwl/cli : 12.1.1 @nrwl/cypress : 12.1.1 @nrwl/devkit : 12.1.1 @nrwl/eslint-plugin-nx : 12.1.1 @nrwl/express : Not Found @nrwl/jest : 12.1.1 @nrwl/linter : 12.1.1 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : 12.1.1 @nrwl/schematics : 8.12.11 @nrwl/tao : 12.1.1 @nrwl/web : 12.1.1 @nrwl/workspace : 12.1.1 @nrwl/storybook : 12.1.1 @nrwl/gatsby : Not Found typescript : 4.3.2
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:7
Top Results From Across the Web
Identify and fix broken builds with CI/CD pipelines | TechTarget
Broken or failing builds in a CI/CD pipeline can deteriorate a team's faith in its own processes. It can also hinder a team's...
Read more >Troubleshoot pipeline runs - Azure DevOps - Microsoft Learn
My pipeline is failing on a command-line step such as MSBUILD. It is helpful to narrow whether a build or release failure is...
Read more >How to troubleshoot a GitLab pipeline failure
Sometimes builds fail because of a merge conflict. GitLab's merge trains exist to make sure that big problems don't get pushed onto the...
Read more >Build Pipeline Failing - Visual Studio Feedback
Our build pipelines started failing today (unrelated to our code) but the task itself. We run a docker task on a microsoft hosted...
Read more >Troubleshooting CodePipeline - AWS Documentation
Pipeline error: A Jenkins build or test action runs for a long time and then fails due to lack of credentials or permissions...
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
These worked for me
--base origin/master
tonx affected:build
For the ones running into issue on Gitlab CI, two things to make it work;
First; set the git depth via UI to
0
, under settings -> CI CD -> General pipelines -> git depth And second, addGIT_FETCH_EXTRA_FLAGS: --unshallow
in .gitlab-ci.yml under variablesEDIT:
GIT_FETCH_EXTRA_FLAGS: --unshallow
worked only in the first run, for following runs runner throws error:The solution I found is setting the depth as
0
, and passing--base=origin/master
to affected command