Last active
October 29, 2024 14:24
-
-
Save larstobi/ae9db1486ccc4a2ef3405b9b05ba6bfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: Bash@3 | |
displayName: 'Check if Package Exists' | |
inputs: | |
targetType: 'inline' | |
script: | | |
set -e | |
# Configure default organization and project | |
az devops configure --defaults organization=$(System.TeamFoundationCollectionUri) project=$(System.TeamProject) | |
# Authenticate with Azure DevOps | |
az devops login --token $(System.AccessToken) | |
# Attempt to download the package | |
az artifacts universal download \ | |
--feed "$(feedName)" \ | |
--name "$(packageName)" \ | |
--version "$(packageVersion)" \ | |
--path "$(Build.ArtifactStagingDirectory)/temp_download" | |
RESULT=$? | |
if [ $RESULT -eq 0 ]; then | |
echo "Package exists." | |
echo "##vso[task.setvariable variable=PackageExists]true" | |
else | |
echo "Package does not exist or an error occurred." | |
echo "##vso[task.setvariable variable=PackageExists]false" | |
fi | |
# Clean up temporary files | |
rm -rf "$(Build.ArtifactStagingDirectory)/temp_download" | |
set -e # Re-enable exit on error | |
env: | |
SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: UniversalPackages@0 | |
displayName: 'Publish Universal Package' | |
inputs: | |
command: 'publish' | |
publishDirectory: '$(Build.ArtifactStagingDirectory)' | |
feedsToUsePublish: 'internal' | |
vstsFeedPublish: 'YourFeedID' | |
vstsFeedPackagePublish: '$(packageName)' | |
packagePublishVersion: '$(packageVersion)' | |
condition: ne(variables['PackageExists'], 'true') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment