#TFS 2018 Integration

11 messages · Page 1 of 1 (latest)

unkempt zealot
#

In my organization, we use TFS 2018 Update 2+. We have not yet migrated to Azure DevOps. In testing, I have tried to integrate various features with our instance of TFS using the Azure integrations, but they weren't successful. So I find myself with the burden of creating these integrations myself.

The functionality I am currently focused on exposing will include:

  • Create Git Repository (as a scaffolding action)
  • Push generated source to Git Repository (as a scaffolding action)
  • Read catalog-info files from Git repositories by URL
  • Create Build and Release definitions

I have reviewed a bit of the azure code throughout the application, but it's not clear what is what due to there being various plugins and packages with reference to azure.

Is there an integration + auth + scaffolding implemented in any plugins external from backstage that might serve as a good reference?

Or a document for adding new integration?

Or could someone provide a simple outline for the types of things I'd need to do?


thank you for any time you spend helping me or even just reading my question. 🙏

nova sierra
#

Hi @unkempt zealot, I’m probably going to be the one to best answer this. I’m one of the authors of the Azure DevOps plugins as well contributed a few fixes to get Backstage working with Azure DevOps Server (the on-prem version and succor of the version you are on). I’ve also used TFS since the 2005 version. The issue for me is I’m actually on vacation so I can’t give you much technical guidance for a few days.

#

Backstage will work with Azure DevOps 2019 which is one version up from where you are. I highly recommend not wasting your efforts on trying to make it work with TFS but to upgrade.

#

From there the first three bullet points you’ll be able to accomplish. The forth you’ll need to make regardless as there hasn’t been much work done by the community for those. This is another area where I recommended using new features like YAML based multi-stage pipelines. Those are much easier to template and you won’t need to build as much using the Azure DevOps REST API

#

Finally, some clarity around Auth. This would be not be handled by Azure DevOps or TFS but some other system. In my experience people using these have either AD or Azure AD. There is good support for these already so that part should be fairly well covered.

unkempt zealot
# nova sierra Hi <@151870706018287616>, I’m probably going to be the one to best answer this. ...

I saw your status! Thanks for helping out while you're on vacation, but please don't feel obligated.

Wow you have a lot of experience with TFS! We are in the midst of upgrading, but it is still quite a ways out and I am not on the team that supports that. I will see if we can support alternatives, like GitLab. I am guessing no though, due to wanting to link and track work within TFS. Due to this I feel a bit stuck in this effort.

Do you know if 2018 supports yaml based multi-stage pipelines? I haven't seen reference to it before. (I'll check tomorrow in our instance)

We do use AD, and Okta on top of that. I was thinking about the auth provider for the PAT but I guess I would just need one for backstage, not for each user. And it can come from the config.

If I don't get traction on alternatives to TFS2018, can you suggest any plugins or docs I could refer to?

unkempt zealot
#

To start, i am using azure-devops-node-api 6.6.3 (for tfs2018 u2) directly in scaffolding. it seems alright so far, but i need to test it out much more. I'm not sure on good patterns for making scaffolds, but for now just worrying about making it do what i need.

unkempt zealot
#
import * as tfs from 'azure-devops-node-api'
import { IGitApi } from 'azure-devops-node-api/GitApi'
import { GitRepository, GitRepositoryCreateOptions } from 'azure-devops-node-api/interfaces/GitInterfaces'
import { InputError } from '@backstage/errors'

export const createTfsGitRepository = async (orgUrl: string, projectName: string, repositoryName: string, token: string) => {
    const authHandler = tfs.getPersonalAccessTokenHandler(token)
    const connection = new tfs.WebApi(orgUrl, authHandler)

    // Check that the orgUrl is correct
    try {
        const connectionData = await connection.connect()
        if(!connectionData) throw new Error()
    } catch (error) {
        throw new InputError(`Incorrect orgUrl "${orgUrl}" or TFS personal access token\n\t`, error)
    }

    // Check that the project exists
    let project;
    try {
        project = await (await connection.getCoreApi()).getProject(projectName)
        if(!project) throw new Error()
    } catch (error) {
        throw new InputError(`Invalid projectName ${projectName}.`)
    }

    const git: IGitApi = await connection.getGitApi()

    // Check if a repository already exists with this name.
    const repos: GitRepository[] = await git.getRepositories(projectName, true, false, true)
    const checkName = repos.find(repo => repo.name.toLowerCase() === repositoryName.toLowerCase())
    if (checkName) {
        throw new InputError(`Repository with the name "${checkName?.name}" already exists. ${checkName?.webUrl}`)
    }

    // Create repository
    const newRepo: GitRepository = await git.createRepository({ name: repositoryName }, projectName)
    console.log(`Repository created at ${newRepo?.webUrl}`)
}

this ended up working out. I will move forward with this approach in general in scaffolding and other places for now. Until that migration happens....

I highly recommend anyone trying this in the future to just grab azure-devops-node-api@^6.6.3, or the respective version mentioned in their readme... it will at least get you where you need.

#

Thanks @nova sierra for being around to help :) you helped me realize i need to focus in on the minimal effort solution since the migration is in the near future. i hope your vacation was great!!!

nova sierra
#

Hi @unkempt zealot, what you did was what I was trying to say - you're going to have to build a lot of this on your own. You might be the 2nd person I've found on this Discord Server that is using TFS, the majority are on Azure DevOps Services (cloud) and a smaller portion on Azure DevOps Server (on-prem)

#

TFS 2018 does not support the YAML pipelines at all from what I remember. I think basic support was added in Azure DevOps 2019 and then the full multi-stage support came in Azure DevOps 2020. They release a new version late last year so it's now at 2022