-
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
nx affected -- Azure Pipelines #17172
Comments
This command also fails to work:
After defining both, you are still met with the mysterious |
Did you manage to figure it out? |
With the following steps, it seems to work. None of the variables is needed if you don't use Nx Cloud. Regarding the documentation of the affected command, - checkout: self
fetchDepth: 0
- template: 'azure-pipelines-node-setup.yml'
# Set Azure Devops CLI default settings
- bash: az devops configure --defaults organization=$(System.TeamFoundationCollectionUri) project=$(System.TeamProject)
displayName: 'Set default Azure DevOps organization and project'
# Get last successfull commit from Azure Devops CLI
- bash: |
git branch --track main origin/main
DEFAULT_BASE_SHA=main
LAST_SHA=$(az pipelines build list --branch $(Build.SourceBranchName) --definition-ids $(System.DefinitionId) --result succeeded --top 1 --query "[0].triggerInfo.\"ci.sourceSha\"")
if [ -z "$LAST_SHA" ]
then
LAST_SHA=$DEFAULT_BASE_SHA
fi
echo "Last successful commit SHA: $LAST_SHA"
echo "##vso[task.setvariable variable=BASE_SHA]$LAST_SHA"
displayName: 'Get last successful commit SHA'
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken) |
Hi nx team any update : ( |
In my case I just needed it for a pull request. I removed almost everything and just used But I believe you can make it work with the SHA as well. The reason the example on nx.dev is not working, is because you can't use git commands into the azure variables directly, but you could set them as a variable in a step/script. |
I've been playing around with this quite a bit and in short, here's the minimum pipeline that works for me. This assumes you want the build to trigger on any commits to master or any pr's into master. It is still a mystery as to what
In my opinion, the real magic happens after all of this when you have your build artifact (your dist). Figuring out how to get that into production is fairly confusing. In my case, I use docker and after One thing that is worth mentioning is this step:
If that command is failing to work for you, check the build logs. It was random, but in the beginning it forced me to specify some extra arguments such as |
We tried your command but triggerInfo was empty for us. This command worked instead: The build contained the field "sourceVersion" which contained the commit SHA |
Just to add, I had issues getting the NX provided snippet to work. I end up with az pipelines returning an empty value This works for me however
|
The Azure CI docs have been updated a few times since this issue was filed (including one update in progress #23453). Please open a new issue if there are still problems with the current documentation. |
the docs is still wrong it does not works for the PR |
What is the error you get for a PR? |
That would happen if the
|
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. |
Documentation issue
Is there a specific documentation page you are reporting?
Enter the URL or documentation section here.
https://nx.dev/recipes/ci/monorepo-ci-azure#configuring-ci-using-azure-pipelines-and-nx
Additional context or description
Provide any additional details here as needed.
The documentation currently has this snippet:
TARGET_BRANCH
for? There is no usage of it after it is assigned.HEAD_SHA
for? There is no usage of it after it is assigned.$DEFAULT_BASE_SHA
? It is used, but not defined, assigned, or explained.CI
? There is no usage of it after it is assigned.The text was updated successfully, but these errors were encountered: