gt nx affected lint…

2 minute read

```> nx affected:lint

fatal: Not a valid object name master /home/vsts/work/1/s/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:1109 else throw err ^

Error: Command failed: git merge-base master HEAD fatal: Not a valid object name master

at checkExecSyncError (child_process.js:621:11)
at Object.execSync (child_process.js:657:15)
at getFilesUsingBaseAndHead (/home/vsts/work/1/s/node_modules/@nrwl/workspace/src/command-line/shared.js:67:39)
at Object.parseFiles (/home/vsts/work/1/s/node_modules/@nrwl/workspace/src/command-line/shared.js:52:20)
at Object.affected (/home/vsts/work/1/s/node_modules/@nrwl/workspace/src/command-line/affected.js:19:108)
at Object.handler (/home/vsts/work/1/s/node_modules/@nrwl/workspace/src/command-line/nx-commands.js:46:138)
at Object.runCommand (/home/vsts/work/1/s/node_modules/@nrwl/workspace/node_modules/yargs/lib/command.js:235:44)
at Object.parseArgs [as _parseArgs] (/home/vsts/work/1/s/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:1022:30)
at Object.get [as argv] (/home/vsts/work/1/s/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:965:21)
at Object.initLocal (/home/vsts/work/1/s/node_modules/@nrwl/cli/lib/init-local.js:20:79) {   status: 128,   signal: null,   output: [
null,
<Buffer >,
<Buffer 66 61 74 61 6c 3a 20 4e 6f 74 20 61 20 76 61 6c 69 64 20 6f 62 6a 65 63 74 20 6e 61 6d 65 20 6d 61 73 74 65 72 0a>   ],   pid: 3424,   stdout: <Buffer >,   stderr: <Buffer 66 61 74 61 6c 3a 20 4e 6f 74 20 61 20 76 61 6c 69 64 20 6f 62 6a 65 63 74 20 6e 61 6d 65 20 6d 61 73 74 65 72 0a> }```

Responses:

I get this error when running nx affected:lint on Azure Devops Piplines, This is on the master branch. Is there some one that has a clue what is going wrong

Are you trying to run affected on master basing off of master?

did we ever have this issue?

well it is a ci build running on the master, but on a detached head

when your in detached head mode, your not on a branch. You are at HEAD (only on a specific commit) therefore master isnt a branch you have locally (on ci) I am guessing. You’ll probably need to run git fetch and/or git pull to have master availabile in your pipeline. Let me know if this helps

I know with Travis you need to specific more arguments so it isn’t a shallow clone.

Azure might be the aame

im guessing it is the same, less for them to clone

Azure pipelines is just to using a detached head, I can do a git switch to switch to te master branch, so this would be necessary then?

You can see in the log they are fetching a specific commit for their builds

thats a shallow clone then

you need a full clone.

Ok, tnx for the input. I’ll make that change and retry

keep us posted!

Take a look at the sample repos

You should probably set the base flag using remotes/origin/master when on a PR to master or remotes/origin/master~1 when running CI after merge to master.

I know this is a Jenkins CI but the logic should be similar

<https://github.com/nrwl/nx-jenkins-build/pull/3 https://github.com/nrwl/nx-jenkins-build/pull/3>

There is also another PR where I fix the ceiling function

Here is there azure sample

<https://github.com/nrwl/nx-azure-build https://github.com/nrwl/nx-azure-build>

I sent the PR for Jenkins because the logic implemented in the PR should work with semantic-release-plus and allow you to have master, beta, next, and alpha trunks.

It works now with setting the base to origin/master~1 for builds on the master and origin/master for all others

Updated: