-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Jenkins CI - npx nx affected --target=build throws as error #2422
Comments
Jenkins only does a sparse checkout. Have you tried checking out the branch which has to be built/tested etc? |
Could you upload a repro to github? |
Thanks for the response Repo pushed to Github. @mehrad-rafigh, I have not yet verified direct checkout on the Jenkins agent. Will feedback when I get a chance to test |
I have a similar problem - the issue arises when trying to compute affected when there is a shallow clone. Ideally it should be possible to just have a shallow clone of the current branch and the target branch (i.e. only 2 commits pulled for the whole repo). The problem arises in nx/packages/workspace/src/command-line/shared.ts Lines 74 to 81 in 74716df
git merge-base is used to find a common ancestor.
I'm not sure if there is an alternative to |
@zakhenry appreciate the comprehensive response. |
@zakhenry you could pass the files yourself, like this:
Where you generate the list by running |
@vsavkin yep that is true however it will be quite a bit more eager than the git-merge technique as the git diff will pick up every single non matching file, whether or not it was caused by a change in the current branches divergence from the common ancestor. Weighed up it is probably faster overall to just clone deeply. |
@zakhenry yup. Another option, which isn't really a replacement for I'm going to close this issue. I don't think there is a good fix for it. The workaround: Since you can pass the list of touched files directly, you can compute the list in the way that works in your CI env. |
@vsavkin This solution has limitations in the fact that any non-trivial change (e.g. adding in a whole new submodule) will result in a large file list. This has impact on reporting in the CI system as the concatentated list of files will be embedded in the output/headings and the like. This could also have impact on shell limitations on the number of characters that are safely passed for given arguments or overall commmands. Would it be possible to formally support this model via arguments e.g. |
@vsavkin , Just a suggestion, I had the same issue with jenkins where the origin develop was not fetched as jenkins was doing shadow cloning, I resolved the issue by enabling advanced clone option in multibranch pipline and enable fetch tags. It helped me. |
Hello, Does anyone succeded in using nx affected in a jenkins pipeline? |
I don't have a solution, but wanted to share some information. In pipeline jobs, it's not a problem, since you can indicate the branch to build, and sure that you have the base on that branch's last commit. The problem is multi-branch pipelines. And the issue is the affected command requires you to tell it what base you want to compare it to. This branch also needs to be checked out in order for the comparison to work. This is rarely the case - when you have a PR from some other branch (feature* for example) - this is when The solutions above all are trying to solve that issue, how to keep the checkout shallow/fast, but also have everything needed to do the comparison. There are two scenarios, one is where you are building a branch and the other where you are building a PR, they have different env variables and are different. The solution offered in the docs is to use something like this:
This is what is used to generate the base, but this only works in certain situations, like when you are on the main branch, to begin with. @santoshyadavdev 's solution worked for me. |
Looks like you tagged me by mistake 😃 it's @SanthoshKumar-Prodapt |
I think this is worth to mention in the document. |
Just for anyone else finding this thread. @SanthoshKumar-Prodapt fix worked for me ... just make sure you use Also I found it easier to add the command to my package.json and call that from jenkins.
|
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Expected Behavior
Build should execute on Jenkins with same source as executes on local environment
Current Behavior
Source checked into git, Jenkins multi branch pipeline executes
Build stage fails with error:
fatal: Not a valid object name affected
Command failed: git merge-base affected master
fatal: Not a valid object name affected
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
Context
Please provide any relevant information about your setup:
nx report
at the root of your workspace and copy the results here if you are using Nx 8.6.1 or greater)A minimal reproduction scenario allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem.
Failure Logs
Extract of log file included below:
JENKINS_HOME=/var/lib/jenkins
MAIL=/var/mail/ubuntu
SSH_CLIENT=10.33.11.191 35228 22
USER=ubuntu
RUN_CHANGES_DISPLAY_URL=https://tools.symbiotics.co.za/jenkins/job/Symbiotics/job/ResearchAndDevelopment/job/Mike-NXPoC/job/master/1/display/redirect?page=changes
NODE_LABELS=AWSCLI-1.14 EC2 (us-east-1) - Ubuntu slave - general purpose (i-010bf32acc1726c8d)
HUDSON_URL=https://tools.symbiotics.co.za/jenkins/
GIT_COMMIT=822981fd6da97e2d71e35656d41c5b4c32f6bdea
SHLVL=1
HOME=/home/ubuntu
BUILD_URL=https://tools.symbiotics.co.za/jenkins/job/Symbiotics/job/ResearchAndDevelopment/job/Mike-NXPoC/job/master/1/
HUDSON_COOKIE=d35a3660-b7a9-47c5-b8b3-4b5d45c3f71d
JENKINS_SERVER_COOKIE=durable-e8c8bc3e63db0bf107f0b2bd92c8d9d3
JBOSS_HOME=/opt/wildfly-8.2.0.Final
WORKSPACE=/var/lib/jenkins/workspace/AndDevelopment_Mike-NXPoC_master
LOGNAME=ubuntu
NODE_NAME=EC2 (us-east-1) - Ubuntu slave - general purpose (i-010bf32acc1726c8d)
_=/usr/bin/java
STAGE_NAME=Env Setup
EXECUTOR_NUMBER=1
GIT_BRANCH=master
XDG_SESSION_ID=3
BUILD_DISPLAY_NAME=add bazel schematics #1
HUDSON_HOME=/var/lib/jenkins
JOB_BASE_NAME=master
PATH=/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_12.14.1/bin:/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_12.14.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/ubuntu/android-sdk-linux/tools:/home/ubuntu/android-sdk-linux/platform-tools
BUILD_ID=1
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0.0
BUILD_TAG=jenkins-Symbiotics-ResearchAndDevelopment-Mike-NXPoC-master-1
LANG=en_US.UTF-8
NODEJS_HOME=/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_12.14.1
JENKINS_URL=https://tools.symbiotics.co.za/jenkins/
JOB_URL=https://tools.symbiotics.co.za/jenkins/job/Symbiotics/job/ResearchAndDevelopment/job/Mike-NXPoC/job/master/
GIT_URL=https://git.symbiotics.co.za/mike.love/NXPoC.git
BUILD_NUMBER=1
JENKINS_NODE_COOKIE=3d497345-2c4f-4f76-ae5e-5938937842cd
SHELL=/bin/bash
RUN_DISPLAY_URL=https://tools.symbiotics.co.za/jenkins/job/Symbiotics/job/ResearchAndDevelopment/job/Mike-NXPoC/job/master/1/display/redirect
HUDSON_SERVER_COOKIE=32f647d765b2b380
JOB_DISPLAY_URL=https://tools.symbiotics.co.za/jenkins/job/Symbiotics/job/ResearchAndDevelopment/job/Mike-NXPoC/job/master/display/redirect
JOB_NAME=Symbiotics/ResearchAndDevelopment/Mike-NXPoC/master
PWD=/var/lib/jenkins/workspace/AndDevelopment_Mike-NXPoC_master
LC_ALL=en_US.UTF-8
ANDROID_HOME=/home/ubuntu/android-sdk-linux
SSH_CONNECTION=10.33.11.191 35228 10.33.11.19 22
BRANCH_NAME=master
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
v12.14.1
6.13.4
fatal: Not a valid object name affected
Command failed: git merge-base affected master
fatal: Not a valid object name affected
[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] archive
The archive step is deprecated, please use archiveArtifacts instead.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
The text was updated successfully, but these errors were encountered: