Skip to content
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

Update-DocsMsPackages.ps1 Explicitly exits 0 #1977

Merged

Conversation

danieljurek
Copy link
Member

Exit 0 so DevOps doesn't fail the build when the last command called by the domain-specific function exited with a non-zero exit code.

Specifically this mitigates issues in Java where the docindex pipeline fails because an inner mvn command failed during validation. The whole script succeeds because we properly handle errors but PowerShell just reads $LASTEXITCODE

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

Copy link
Member

@scbedd scbedd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a confirmation. We expect the try/catch above this to catch any actual issues that are thrown. This is purely to avoid the mvn command (in that specific example) from setting $LASTEXITCODE explicitly.

@danieljurek
Copy link
Member Author

@scbedd -- Correct. The last execution of an external command sets $LASTEXITCODE and the way that the PowerShell task handles ignoreLASTEXITCODE is:

ignoreLASTEXITCODE: true -- Always succeed even if your script exits with a nonzero exit code. This is bad because the script will be trying to say "I FAILED" but if it doesn't specifically notify DevOps that it has an error (which we do) then exiting with a non-zero exit code will have no effect.

ignoreLASTEXITCODE: false (default) -- If you call an external tool in the script (like mvn) and the last call to the external tool has a non-zero exit code then $LASTEXITCODE is set to a non-zero value. When ignoreLASTEXITCODE is false DevOps adds a condition to the bottom of the wrapper script which calls your script... So your script may succeed (even though an external tool set a non-zero exit code) but the script itself doesn't set $LASTEXITCODE unless explicitly calling exit. This explicitly calls exit in the success case.

@benbp
Copy link
Member

benbp commented Sep 2, 2021

This is why I've been getting all those docindex failed emails...:D

danieljurek added a commit to Azure/azure-sdk-for-java that referenced this pull request Sep 8, 2021
* Fix variable names for $remainingPackages

* Route stderr to stdout to prevent errors in mvn from breaking the docs onboarding process

* Stringify potential error objects

* Out-String

* Redirect artifact download output

* Out-Null

* Test exit 1

* Test powershell task behavior

* Test powershell task behavior

* Test powershell task behavior with an explicit exit 0

* Sparse checkout Java repo

* Revert Update-DocsMsPackages.ps1. Those changes are coming in Azure/azure-sdk-tools#1977

* Revert changes to Language-Settings.ps1 to use intended variable changes only

* Tweak sparse checkout

* Use a single checkout: none

* Use default checkout

* Revert to original SkipDefaultCheckout: true

* Update eng/scripts/Language-Settings.ps1

Co-authored-by: Ben Broderick Phillips <[email protected]>

Co-authored-by: Ben Broderick Phillips <[email protected]>
@chidozieononiwu
Copy link
Member

/azp run azure-sdk-tools - sync - eng-common

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@chidozieononiwu
Copy link
Member

/azp run azure-sdk-tools - sync - eng-common

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@danieljurek danieljurek force-pushed the update-docsmspackages-explicit-exit-code branch from 6125b91 to 31371ed Compare September 9, 2021 04:37
@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@ghost
Copy link

ghost commented Sep 9, 2021

Hello @azure-sdk!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit e094b9f into Azure:main Sep 9, 2021
@danieljurek danieljurek deleted the update-docsmspackages-explicit-exit-code branch September 9, 2021 18:07
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants