# How can I include an artifact in a release created from TFS?

Hello. I have a working build process in TFS that creates a package for each of my projects, pushes them to Octopus, and creates a release using the steps included in the Octopus TFS extension. I would like to include a text file generated by the build server as an artifact in the release when/after it is created, so that it appears in any deployments of the release.

Is this possible? If so, how can I go about doing this? Thanks.

Hi @mdk ,

Thank you for contacting Octopus Help with regards to making Octopus grab a copy of an output file from your TFS build server.

Once you’ve given the step the details about your build server, the artifact details are as follows:

Looking through the TeamCity documentation, I note there is this page: Build Artifact | TeamCity On-Premises (onprem) and Build Artifact | TeamCity Cloud (cloud) on downloading artifacts, which may help in getting things setup on the TC side of things.

I hope that helps!

Regards

Mark

Mark Lamprecht

Solutions Architect | St Ives, Cambridgeshire, UK

[image]

Hi @mdk ,

Further to your request for help. I’ve just realised that the step I’ve referred you to will only download the file, not turn it into an Octopus artifact.

If you want an Octopus artifact, then you’ll need another step after that which turns it into an artifact.

If you use the Run A Script step, then add this PowerShell code, it will grab the downloaded text file and add it to the deployment as an artifact:

New-OctopusArtifact -Path "\path\to\teamcity\artifact" -Name "artifact-name.txt"

The -Path is the folder path to the already downloaded file from the TeamCity - Download Artifact step, and the -Name is up to you i.e. the downloaded file can be given the same name as when it was downloaded or you can give it an entirely different name if you so wish.

Regards

Mark

Mark Lamprecht

Solutions Architect | St Ives, Cambridgeshire, UK

Hi @Mark_Lamprecht, thanks for the reply. Just to be clear, I’m building with TFS (Team Foundation Server), not TeamCity. Are you saying the TeamCity Download Artifact step will also work with TFS?

Hi @mdk ,

That is my mistake and I’m so sorry!

So given you’re working with TFS, as long as you can put the text file generated by the release in a (shared?) folder that your Octopus server has access to, then you can still use the PowerShell…

New-OctopusArtifact -Path "\\sharedpath\to\tfs\artifact" -Name "artifact-name.txt"

…in a Run A Script step to grab a copy of the TFS file and save it as an Octopus artifact during deployment.

As before the -Path is the folder path to the file generated by TFS and the -Name is up to you i.e. the TFS file can be given the same name as when it was generated by TFS, or you can give it an entirely different name if you so wish.

Regards

Mark

Solutions Architect | St Ives, Cambridgeshire, UK

I see, thanks. I can probably make that work, but it would be simpler for me to push the artifact from TFS (using the existing service connection and API key) than pull it from Octopus. I suppose there’s no way to do that?

Alright, never mind, I was able to have the build server store the file within an existing package. The PowerShell script in Octopus can now just simply extract the package and save the file as an artifact.

Hi @Mark_Lamprecht, I now have a separate issue with this process update that I’m trying to figure out. This is the script step I added to the deployment:

I can create a release within Octopus just fine, and can select the relevant packages for this step:

However, the TFS build server is now unable to create a release using the step included in the Octopus TFS extension. It throws this error:

I have always specified the package version for all steps using the Octo.exe argument --packageVersion $(Build.BuildNumber), and also tried using --package FTDatabase:$(Build.BuildNumber) --package RTDatabase:$(Build.BuildNumber) to no avail. Do you have any thoughts as to what the problem could be or how to fix it? Thank you. Hi @mdk , Talking to a colleague with more experience in this area, they mentioned that you could try: --package "Create combined Database Script Artifacts:FTDatabase"=$(Build.BuildNumber)

…instead for FTDatabase, and ditto for RTDatabase - but obviously with RT instead of FT.

Regards

Mark

Mark Lamprecht

Solutions Architect | St Ives, Cambridgeshire, UK

Thanks @Mark_Lamprecht. That didn’t solve the issue, but while editing the Octopus release step I did notice that it hadn’t been changed in a long time and was a couple versions out of date. Updating it to the latest version fixed the problem. Seems like that old version didn’t actually support referenced packages. Sorry for the time-waster, but it’s all running smoothly now.

1 Like

Hi @mdk

All good - that was going to be one of my next questions so I’m glad you spotted it ahead of me, and I’m also glad to hear things are working as expected!

Regards

Mark

Mark Lamprecht

Solutions Architect | St Ives, Cambridgeshire, UK