I have code repo held in Collection 1 and, using this code repo, I am trying to create a Build artifact and Release definition in a different Collection 2.
Is this even possible?
DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure. It only takes a minute to sign up.Sign up to join this community
Since on-premise TFS and the newly renamed Azure DevOps Server 2019 still have the concept of collections, which is the highest level of separation of data you can have (separate physical databases), you'd need to treat a code repo in Collection 1 as an external repository rather than try to discover it as a known internal repository.
You can do this in the Build pipeline of a build in Collection 2 by selecting External Git (if your repo is Git, TFVC is not supported), then clicking
Add Connection and entering the Git repository URL and login credentials like in the screenshot below. Once connected, your pipeline, if it produces artifacts, will store them in Collection 2, which can be used for a Release pipeline.
In Azure DevOps there is no Collection - there is a project and there are organizations which hold zero or more projects. There is also a distinction between the code repositories and the builds and between the builds and the release mechanism.
Within a build pipeline it is entirely possible to reference a different projects repository to pull into the build and that repository could be in GitHub, Gitlab, or another VSTS organization, and within a release it is entirely possible to include build artifacts from multiple build pipelines.
TFS on-premises depends highly on how up-to-date it has been kept. The most recent versions are feature equal or close to it with Azure DevOps and the above should be true. Milage may vary in older versions.
It isn't clear here in your question though what you are trying to achieve or what you've tried so far.