Azure Artifacts - where to find vstsFeed and vstsFeedPackage to set values of UniversalPackages task - azure-devops

I am using Azure DevOps UniversalPackages#0 task to download from an Azure Artifacts feed. I am using this link to set the values of UniversalPackages#0 task. By looking into my Azure DevOps project artifactory, no where can I find the two arguments vstsFeed and vstsFeedPackage. These values are mandatory for the task:
- task: UniversalPackages#0
displayName: 'Download Artifact with Universal Packages'
inputs:
vstsFeed: '****'
vstsFeedPackage: '****'
vstsPackageVersion: 0.8.4
Please note that I know by using classic editor and using universal packages task I can generate the yaml file. But that's not what I want. I want to know how via DevOps API or from the DevOps portal I can find these two values and put them in the above code.
Here is what I see when I check my feed in Azure Artifacts. As you see no where these values (vstsFeed and vstsFeedPackage) are mentioned.

Instead it is something like: vstsFeed: '00000000-0000-0000-0000-000000000000/00000000-0000-0000-0000-000000000001'
This vstsFeed is composed of projectid and feed id. For example: vstsFeed: Projectid/Feedid
To get the Vsts feed id and the package id, you can use Rest API: Artifact Details - Get Packages
GET https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Feeds/{feedId}/packages?api-version=7.0
In the Response, you can get the project id , feedid and package id.
The task also supports defining feed name and package name.
For example:
- task: UniversalPackages#0
displayName: 'Download Artifact with Universal Packages'
inputs:
vstsFeed: 'projectname/feedname'
vstsFeedPackage: 'package'
vstsPackageVersion: 0.8.4

You have to return one level to Artifacts view. Then, in the drop down menu, there is Artifact feed name (vstsFeed), and below there are Artifact feed packages (vstsFeedPackage - in your case "py_dataenginee..." without semantic version at the end).
More details in picture
According to the documentation, the values in your screenshot are named differently, but still able to pair them according the documentation:
vstsFeed - Feed
vstsFeedPackage - Package name
source https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/universal-packages-v0?view=azure-pipelines
I've added notes to your screenshot.

Related

DevOps - Where to view dependency check report? E drive?

I have an Azure DevOps pipeline step failing running the OWASP dependency check. I want to find what dependencies need to be updated.
The logs that are written during the dependency check pipeline step say:
[INFO] Writing report to: e:\vsts\a\7567\TestResults\dependency-check\dependency-check-report.html
I assume this dependency-check-report.html is where it will tell me what dependencies need to be updated. But I do not understand where this e:\vsts\a\7567\TestResults\ location is, as this step is being run in DevOps. Is this somewhere in DevOps? I cannot seem to find it anywhere. "Download logs" on the pipeline page doesn't seem to have it either.
where this e:\vsts\a\7567\TestResults\ location is
When you run the pipeline in Azure DevOps, this path represents the local path of the machine where the agent locates.
In your case, the agent is self-hosted agent. You go to the local machine where the agent locates and find the dependency-check-report.html in e:\vsts\a\7567\TestResults\dependency-check.
On the other hand, you can use the Publish Pipeline Artifacts task to upload the target file to Pipeline artifacts.
For example:
steps:
- task: dependency-check-build-task#6
displayName: 'Dependency Check'
inputs:
projectName: test
scanPath: test
continueOnError: true
- task: PublishPipelineArtifact#1
displayName: 'Publish Pipeline Artifact'
inputs:
targetPath: '$(Common.TestResultsDirectory)'
artifact: drop
Note: You need to set the continueOnError: true in OWASP dependency check task.
In this case, the dependency-check-report.html on agent machine will be uploaded to Azure Artifacts.
For example:

AzureDevOps-YML-pipeline Get PublishBuildArtifacts URL in yml pipeline

Is there any possibility to get the URL of a published artifact in the yml pipeline, so it can be used in further pipeline tasks/steps?
Sadly, the Microsoft Docs on the two tasks don't give any hints if the published path value is available in any way.
- task: PublishBuildArtifacts#1
inputs:
pathToPublish: report.html
artifactName: HtmlReport
It depends on where you're using the artifacts - Deployment jobs will typically automatically download the artifacts into the $(Pipeline.Workspace) folder with the same name as you declare in the build task.
So in your case it would be located at $(Pipeline.Workspace)\HtmlReport
You can also use the Download Build Artifacts task to download a specific artifact:
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'HtmlReport`
This is useful if you have multiple published artifacts and you only want to download one of them in a later stage. There are other options if you wish to download an artifact from a different pipeline.
Note that the Publish Build Artifacts task is now deprecated and you are recommended to use the newer Publish Pipeline Artifacts and matching Download Pipeline Artifacts tasks:
We recommend upgrading from build artifacts (PublishBuildArtifacts#1 and DownloadBuildArtifacts#0) to pipeline artifacts (PublishPipelineArtifact#1 and DownloadPipelineArtifact#2) for faster performance.

Artifact feed for entire organization?

I have many related projects in my organization. When I create an artifact (nuget package) for any project I want to publish that package to a single organization-level feed.
I also want all my projects to consume packages from this feed.
Is this possible?
I currently reference feeds from projects I need to reference as shown in the YAML below - which does not work. With respect to the first question I asked above, what is the correct way to reference packages I need to consume from my local feeds?
task: NuGetCommand#2
inputs:
command: 'push'
feedsToUse: 'select'
vstsFeed: 'Domain.Project/OtherProject#Local'
publishVstsFeed: 'Domain.Project/OtherProject#Local'
First we can create an organization-scoped feed in Artifacts:
Then specify your local package path and target feed location in nuget push task, for example:
- task: NuGetCommand#2
inputs:
command: 'push'
packagesToPush: '..\xx\NuGetPackage\xx.0.0.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'xxxx'
Run the pipeline with the self-hosted agent to push the local package to the organization scope feed of azure artifact.
Default pool: Use it to register self-hosted agents that you've set up.
pool:
name: Default

Download Artifact from other pipeline in Multistage YAML

In azure devops i am trying to create a multistage release definition via yaml. Build is done via classic editor and the artifacts are uploaded to azure pipelines. so i want to access a specific artifact for deployment
- task: DownloadPipelineArtifact#2 displayName: 'Download Pipeline Artifact' inputs: buildType: specific project: 'vvxxxxxx-vxxv-xxxv-vxxx-xxxxxxvvxxvv' definition: 5 buildVersionToDownload: specific pipelineId: 'SSE_XXXXXXXXXXXXXXXXXX_Auto-import_dev_20200423.4' artifactName: Service targetPath: '$(Pipeline.Workspace)'
When i try it via classic release using task 'Download Pipeline Artifact' it's successful but when I try it via yaml it's failing with error "##[error]Run Id is not valid: SSE_XXXXXXXXXXXXXXXXXX_Auto-import_dev_20200423.4"
if there is anyother way to get the artifact from a pipeline would be helpful and also instead of hardcoding pipelineId I want to make it dynamic as well.
Download Artifact from other pipeline in Multistage YAML
The value of the pipelineId should be the ID of the build pipeline, which you want to download, rather than the name/title of the build pipeline.
Find the build pipeline you want to download, click on a build record you want to download, you could see it in the web address bar of the browser:
also instead of hardcoding pipelineId I want to make it dynamic as
well.
If you don't want hard code the pipelineId/runid in YAML definition, you can consider to pass queue variable as a work around.
For example:
- task: DownloadPipelineArtifact#2
inputs:
source: 'specific'
artifact: 'drop'
path: $(Build.SourcesDirectory)/bin
project: 'AndroidBuild'
pipeline: 12
runVersion: 'specific'
runId: $(buildid)
In above definition, buildid is the variable, and you can configure its value at queue time:
This do not need you to do any modification to the pipeline when you want to choosing another runId, just pass the value at queue time.
Hope this helps.

Azure DevOps release pipeline: Angular and .NET Core application

We're trying to release an Angular 7 / .NET Core application into Azure using the DevOps release pipelines. I have my build setup to create the .NET and Angular builds as separate artifacts which you can see in the screen shots below (under the Package or Folder box).
From what I've read it seems that you need to create two separate release tasks to deploy the builds to the web app. However the second build seems to be overriding the first which is causing the API not to start.
Does anyone know of a way to ensure the deployments in a given stage simply appends the changes rather than replacing them? Or is there something else I am missing here?
My recommendation would be to implement the following pattern for your pipeline:
'ng build --prod' the angular app in it's own job, and add the artifacts to your pipeline
'dotnet publish' the dotnet core api in it's own job, running in parallel with the angular job, and add the artifacts to your pipeline
Append the Angular and Dotnet Core artifacts together into a new artifact. This serves as your final package to deploy
Deploy the final package
You're missing step 3, so you'd want something like the following logic defined in YAML, where you create a new zip that represents your actual deployed bits in your pipeline. Then release that artifact, since it is the representation of what you have running on your instances.
- job: CreateReleaseArtifact
displayName: 'Package for shared-hosting of angular app and web api'
pool:
vmImage: windows-2019
dependsOn:
- BuildNetcore
- BuildAngularApp
condition: succeeded()
steps:
- checkout: none
- download: current
- task: CopyFiles#2
displayName: 'Copy WebApi Files'
inputs:
SourceFolder: $(Pipeline.Workspace)/api
Contents: '**/*'
TargetFolder: $(Pipeline.Workspace)/package
includeRootFolder: false
- task: CopyFiles#2
displayName: 'Copy Angular Files'
inputs:
SourceFolder: $(Pipeline.Workspace)/webapp
Contents: 'wwwroot/**'
TargetFolder: $(Pipeline.Workspace)/package
includeRootFolder: true
OverWrite: true
- publish: $(Pipeline.Workspace)/package
artifact: package
Does anyone know of a way to ensure the deployments in a given stage simply appends the changes rather than replacing them?
Based on my experience, in your case, after deploy the API or Angular 7, then I you could use the Kudu zip API to upload another one to the Azure WebApp.
You could use the Powershell task to do that. For more inforamtion about powershell demo code, you could refer to this link.
If creating another WebApp is acceptable, you could add a new WebApp and use the same service plan (no extral cost). Then you could deploy them separately.