How to manually publish a file to Azure Artifacts? - azure-devops

I have a file which I have created manually on my local computer. I need it in several Azure DevOps pipelines.
I want to use it as an "Artifact".
I know how to publish artifacts from within an Azure DevOps Pipeline, but this specific file I just want to upload from my computer. How can I do it?

How to manually publish a file to Azure Artifacts?
As we know, the essence of Artifact is the storage of a shared file. We can roughly get this information from the Publish build artifacts task:
But the default value of Artifact publish location is Azure Pipelines:
This is a shared place set up on Azure.
Update:
Thanks hey sharing:
We could upload from local to the shared place with AZ command line, like:
az artifacts universal publish --organization https://dev.azure.com/example/ --feed my_feed --name my-artifact-name --version 0.0.1 --description "Test Description" --path
Now let us return to the first sentence we started with "the essence of Artifact is the storage of a shared file", so we could create a shared place/folder to save the file. It is now seen as "Artifact". Then we just need make sure other pipelines could access this shared place/folder.
For example, we could create a folder on the server where our private agent is located, then we just need to copy your file to that folder. Now, we could use it when we build the pipeline with private agent. Obviously this is not limited to local folders, we can also create a network folder, only need to ensure that other pipelines can access it.
Hope this helps.

You have to push it through your package manager like NuGet, npm or anything else. But I guess better option would be commit and push this single file to specific repo (if this file is specific to single project) or common repo like "Utilities" (if you gonna reuse it across many projects) and then download this repo (or just file) in your pipeline.

Related

Is there an equivalent of GitHib releases in Azure DevOps?

Simply speaking, does Azure Devops have something that works very close to GitHub releases?
I would like to publish artifacts that are created during an Azure DevOps pipeline so that they be easily viewed and downloaded afterwards in a central location. The closest equivalent to what I'm looking for is how GitHub releases work, where there is a web page listing out all the versions of the repository and the assets that can be downloaded for each version.
It seems to me that published artifacts within Azure DevOps pipelines are always tied to the run of the pipeline, and there isn't an easy way to see one list of artifacts that have been created in a historical view like GitHub releases provides, but maybe I'm missing something.
Azure Artifacts does not meet my needs because it is tied to particular packaging formats and is meant to be used for developer tooling.
I would like to publish artifacts that are created during an Azure
DevOps pipeline so that they be easily viewed and downloaded
afterwards in a central location.
As a workaround ,you can switch Artifact publish location to A file share in Publish Pipeline Artifacts task then specify your network drive folder path.
Specifying the path to the file share where you want to copy the files. The path must be a fully-qualified path or a valid path relative to the root directory of your repository. Publishing artifacts from a Linux or macOS agent to a file share is not supported.
Besides, there should be no other built-in hosting, I am afraid that Azure Artifact is the closest to your needs. because it is tied to particular packaging formats you can consider using Universal Packages.

Can we copy data from azure file share to azure artifacts

Is it possible to copy files from Azure files shares to azure artifacts using build pipeline task?
Yes it is possible. What you need is actually download files for Azure Files and publish them to Azure Artifacts. Please check this topic where is shown a way how to download files from Azure Files.
Azure Artifacts is a package feed and thus it depends what kind of package you want to publish, so confoguration may differ. But if you want to publish this as build/pipeline artofacts you may simply use regular tasks.

how to deploy artifact of VM desktop?

I tried to copy task extension on azure pipeline: $vmFolder="c:/users/[username]/desktop and also tried
$vmFolder="c:/users/public/desktop but still my artefacts are deployed inside c:/azagent/work/ location. If anyone has an idea, please explain me the process step by step.
Could you provide a little more detail about what you're trying to achieve?
My feeling is that there may be a confussion about what is an Agent (C:\azagent\work is the work directory in a machine where you, very likely, have installed an Agent) and the Machine where you want to deploy your code to run.
Bests.
When you publish the build artifacts in Azure DevOps, for the location you could only choose "Server" or a UNC file share.
Artifact publish location argument:
Azure Pipelines/TFS (TFS 2018 RTM and older: Artifact type: Server)
is the best and simplest choice in most cases. This choice causes the
artifacts to be stored in Azure Pipelines or TFS. But if you're
using a private Windows agent, you've got the option to drop to a
UNC file share.
More details please refer our official doc -- Artifacts in Azure Pipelines
The remaining alternative is to add a download artifacts task in the end of pipeline to download your published artifacts to your Destination directory.

Download build artifacts from file share does not show drop folder content

At the end of the build, I publish artifacts to a file share drive.
But in the release pipeline, if I select the Agent job, I don't see the content of the drop folder, as shown below. Do I have to use a Download Build Artifacts task to go around this ? Or can I still use this option of the Agent job somehow ?
The artifacts were correctly published to the file share. However I also noticed that I cannot open the artifacts folder from the build log. I only see the path. How come ?
Download build artifacts from file share does not show drop folder content
This is an expected behavior. When we choose publish artifacts to a file share drive instead of Azure pipeline, the share drive can be our local path or a network shared folder.
So this share drive is more controlled by us than azure devops. In this case, Azure devops cannot provide a direct download link, only the path where we store the file.
Do I have to use a Download Build Artifacts task to go around this ?
Or can I still use this option of the Agent job somehow ?
It depends on whether your agent running your release pipeline can access your share drive.
If yes, just like Shayki Abramczyk said, the agent will download the artifacts from the file share at the beginning of release.
Note: You need set the build pipeline as artifact source:
The output:
If the agent could not access that share drive, we need use the task like Download artifacts from file share to download the artifact.
Hope this helps.
This is the behavior of publishing to a file share, you can't "explore" the files inside Azure DevOps if it stored on a file share.
You don't need to use the Download Build Artifacts task because the agent will download the artifacts from the file share at the beginning of his run.

How to download files from self hosted VM to VSTS

I have python solution which resides in VSTS repository. Using build pipeline and private agent, the source code gets copied to VM.
After executing the python files, output is stored in 3 different files at the source directory level.
I want to download/copy these output files from private hosted VM to VSTS repository.
How can this be achieved?
Thank you
The only way to get something into the repository is by checking it in via source control.
Maybe it's enough for you to just publish these files as a build artifact. You have the option to publish directly to VSTS or to any Windows file share.
If you really want these files in your repository I'd suggest you publish them as build artifacts and check them in with a release pipeline. You could add a new stage in your existing release pipeline or add a new release pipeline that triggers automatically every time your build completes.
You can call git command to add and push changes to repository, for example:
Check Allow Scripts to access the OAuth token option
Add Command Line task (Tool:git; Arguments: add [file path]; Working folder: $(System.DefaultWorkingDirectory))
Add command line task (Tool:git; Arguments: commit –m “add build result”; Working folder: $(System.DefaultWorkingDirectory))
Add command line task (Tool: git; Arguments: push https://test:$(System.AccessToken)#{account}.visualstudio.com/{project}/_git/{repository} HEAD:master
Related article: Keep Git repository in sync between VSTS / TFS and Git
On the other hand, the better way is publishing the result files as artifact of build through Publish Build Artifact task.