Is it possible to download the secure file to local machine or view its content in Azure DevOps with build administrator privilege? - azure-devops

We have a few already running pipelines in Azure DevOps with dbt orchestration. The profiles.yml file required for the dbt tasks in the pipelines was uploaded to the secure file in DevOps a long time ago.
Now, we have built a new pipeline by orchestrating dbt. As we can't have two profiles.yml files, we are required to update the existing one in the secure file in DevOps.
Also, we have not seen the content of the existing secure file so we are afraid to make the decision to replace the existing file because it would impact the already running pipelines.
Could you please let me know whether we have any possible solution to download the secure file to our local machine or view its content in DevOps if we have the build administrator access?
Thanks.

I am afraid that you are not able to directly download the file to local machine.
I suggest that you can use the Download secure file task to download the secure file and then you can upload the secure file to Build artifacts.
Here is an example:
steps:
- task: DownloadSecureFile#1
displayName: 'Download secure file'
inputs:
secureFile: Certificates.p12
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(DOWNLOADSECUREFILE.SECUREFILEPATH)'
You can find the secure file in Build artifacts.

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:

Download a secure file to repo code in Azure Devops Pipelines

I am creating a Pipeline to automatically build and release a flutter app. On my machine the flutter build appbundle --release works just fine and also signs the app correctly. I reference a key and a properties file, which I both don't want to upload into the repo, but instead use the Library > Secure Files.
How can I either download these files onto my Agent to a specific position, or use the downloaded file path in my build.gradle?
You can utilize "Download Secure File task" to download from the library on to your agent.
reference: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-secure-file?view=azure-devops
https://learn.microsoft.com/en-us/azure/devops/pipelines/library/secure-files?view=azure-devops
- task: DownloadSecureFile#1
inputs:
secureFile: 'secureFile'
- task: CopyFiles#2
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: secureFile
TargetFolder: '$(Build.ArtifactStagingDirectory)'

Unable to publish to File Share in Azure build pipeline

I am switching our pipelines from using on-prem build agent pool to a Hybrid Activation build agent (on-prem server with SSM Agent installed).
I am hitting a small issue when building our artefact. Our build pipeline does not seem to be able to publish the build artefact to the below File Share path on the new agent pool:
\\vwcnexstore08.comp.internal.corp\tfs_scm_drop\BuildDrops\$(System.TeamProject)\$(Build.DefinitionName)\$(Build.BuildNumber)
I am getting this error when I run the build:
Publishing build artifacts failed with an error: Unable to create directory '\\vwcnexstore08.comp.internal.corp\tfs_scm_drop\BuildDrops\CarEvaluator\CarEvaluator (dev branch)\CarEvaluator (dev
branch)_2.0.0293\drop'.
Unable to verify the directory exists: '\\vwcnexstore08.comp.internal.corp\tfs_scm_drop\BuildDrops\CarEvaluator\CarEvaluator (dev branch)\CarEvaluator (dev branch)_2.0.0293\drop'.
If directory is a file share, please verify the share name is correct, the share is online, and the current process has permission to access the share.
This is my PublishBuildArtifacts task
steps:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
publishLocation: FilePath
TargetPath: '\\vwcnexstore08.comp.internal.corp\tfs_scm_drop\BuildDrops\$(System.TeamProject)\$(Build.DefinitionName)\$(Build.BuildNumber)'
Note: The above used to work fine with the previous Agent pool
Could someone please share what I am doing wrong?
Unable to publish to File Share in Azure build pipeline
According to the document Publish Build Artifacts task:
The path must be a fully-qualified path or a valid path relative to the root directory of your repository.
So, you should make sure the TargetPath could be access on your on-prem server.
On the other hand, if the TargetPath is not share for everyone, the project build service account (“BuildService (orgname)”) is in the whitelist for access.

How to generate DACPAC file

I'm trying to deploy my project in Azure DevOps through IIS website and SQL deployment. However I am struggling with deploying SQL part as I do not have a .dacpac file in my build artifacts. How do I generate this as any option that I have tried it ended up with failing of the process.
P.S. I do not have access to the VM where I am deploying due to restrictions. I can access database as I marked as DBO on the machine.
My question is also, do I need to generate this DACPAC file through build every time or it can be generated only once, stored on machine, and I point from deployment process to that file?
Thank you for your help!
However I am struggling with deploying SQL part as I do not have a .dacpac file in my build artifacts. How do I generate this as any option that I have tried it ended up with failing of the process. I can access database as I marked as DBO on the machine.
Firstly you have to create SQL Server Database Project using SSDT (or Azure Data Studio insiders preview) by importing objects of the live database.
The database project then is to be placed into a repository
The pipeline (classic or yaml) is to have a build task MSBuild#1. Here is an YAML example. It generates the dacpac
- task: MSBuild#1
displayName: 'Build solution YourDatabase.sln'
inputs:
solution: 'src/YourDatabase.sln'
This task compiles the database project and produces dacpac file(s)
Then produced files are to be extracted:
- task: CopyFiles#2
displayName: 'Extract DACPACs'
inputs:
CleanTargetFolder: false
SourceFolder: '$(agent.builddirectory)\s\src\YourDatabase\bin\Debug\'
Contents: '*.dacpac'
TargetFolder: '$(build.artifactstagingdirectory)'
And finally, published as the artefact
- task: PublishPipelineArtifact#1
displayName: 'Publish Artifact'
inputs:
targetPath: '$(build.artifactstagingdirectory)'
artifact: 'drop'
Deployment of the dacpac is the final goal and can be done using SqlDacpacDeploymentOnMachineGroup#0, however, this is out of the scope of the original question
My question is also, do I need to generate this DACPAC file through build every time or it can be generated only once, stored on machine, and I point from deployment process to that file?
It depends.
Classic pipelines have a separation of BUILD and RELEASE phases. In this case, you can build it once and reuse that dacpac for many future releases.
In case of multi-stage yaml pipelines, it is common that every pipeline run triggers build and deployment stages, because they are still belong to the same pipeline and run as a single unit work.

How to find or add azure pipeline application published output folder for upload those files in to FTP

In the azure pipelines I'm trying to build a CI. I have added 'dotnet publish' in the agent job. But after publish, my application I have no idea where is those published files. There are no input field for enter output path.
I tried to use 'publishing artifacts' but it get wrong files
Here is my dotnet publish YAML
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
workingDirectory: WebApplication1
How to find or add azure pipeline application published output folder for upload those files in to FTP
You can add the Arguments --output $(build.artifactstagingdirectory) in the Arguments option to specify the output path:
Then it will zip as one zip file(a.zip) in the $(build.artifactstagingdirectory) and you could use publishing build artifacts task to get it.
Hope this helps.