Using teamcity with TFS, is it possible to run shelveset without unshelving it first to my workspace? I found way to only run it from pending changes (therefore unshelved), but it seems weird this is not possible.
Using Visual Studio 2008 and teamcity adding 8.1.
That feature is not currently built into TeamCity's TFS VCS plug-in.
As a work-around, you can do this using a custom build configuration parameter and a custom build step that automatically unshelves the shelveset before the build.
I created a feature request here: https://youtrack.jetbrains.com/issue/TW-43793
Manual work-around:
Create a new build parameter:
Name: ShelvesetName
Kind: Configuration parameter
Spec: text description='The shelveset to unshelve in the format |[shelvesetname|[;username|]|]' label='Shelveset Name' validationMode='any' display='normal'
Create a new build step:
Runner Type: Command Line
Step name: Unshelve shelveset
Execute step: If all previous steps finished successfully
Run: Custom script
Custom script:
if "%ShelvesetName%"=="" exit /b 0
"%VS2013_Path%\tf.exe" unshelve "%ShelvesetName%" "%vcsroot.vcsroot-name.tfs-root%" /recursive /noprompt /login:domain\username,password
You may have to change VS2013_Path with the appropriate variable/parameter from the agent and the version of Visual Studio you're using.
You'll have to change vcsroot-name with the name of your vcs root, and remove the /login parameter or specify your own credentials.
The VCS root checkout mode must be set to Automatically on agent (if supported by VCS roots) for TeamCity to create a TFS workspace so this can work correctly.
Then finally, when you run a custom build, set the Shelveset Name field on the Parameters tab to the name of the shelveset, including the owner, like shelveset1;domain\username.
Related
I am attempting to create a build definition in TFS 2015 that is triggered after a Pull Request is created. It is triggered as part of a Branch Policy (Automatically Build Pull Requests).
I have a Command Line build task that uses the following:
Tool: C:\Path\To\My.exe
Arguments: $(System.PullRequest.PullRequestId)
My .exe creates folders and files depending on the PR ID from TFS. One of the folders is a direct copy of the PR ID (so the folder would be named "25" for PR 25).
Here is what my folder name looks like after my build runs successfully:
$(System.PullRequest.PullRequestId)
As you can see, it is not evaluating the ID at build time.
How do I pass the PR ID to a command line executable build task using TFS 2015?
It turns out that the $(System.PullRequest.PullRequestId) variable is not supported in TFS 2015.
I upgraded our TFS installation to Azure DevOps Server 2019 and it fixed the issue.
I found a List of TFS Environment Variables on the web that helped me with my answer.
I am trying to run a Jenkins job that uses TFVC plugin. We earlier had a problem with length of the TFS workspace names (exception for length > 75 chars). In order to address this we made a change in the TFVC configuration.
Default workspace name in TFVC: Hudson-${JOB_NAME}-${NODE_NAME}
After change: Hudson-${JOB_NAME}
Post this change the job had one successful run. We are unable to run this repeatedly as the TFS workspace created during the successful run was not deleted. and is throwing the following exception:
FATAL: hudson.remoting.ProxyException: com.microsoft.tfs.core.exceptions.TECoreException: The workspace scanAPI;tfsjenkins already exists on computer ip-XX-XX-XX-XX.
I have tried deleting the Jenkins workspace in pre/post build steps. This has no impact on the TFS workspace.
Additional information: The jobs are being run on a linux node and hence I am unable to run windows commands
You can use Post Build script that use tf.exe to delete the TFVC workpsace, with the delete command.
Create a global environment variable to be able to access the TF.exe easier. for example:
Note: the path to tf.exe it depend to which Visual Studio is installed in the Jenkins machine.
Add a Windows batch command from the scripts menu with the following command:
%TFS% workspace /delete /noprompt /collection:”https://tfs.codeplex.com:443/tfs/TFS27″ “Hudson-%JOB_NAME%;snd\7astlivec_cp”
Replace the URL with your TFS Server URL and change snd\7astlivec_cp with your TFS user. The command is going to delete the newly created TFS workspace.
Another option is to add tf.exe. location to the machine PATH variable and use it directly: tf workspace /delete .......
Update
For Linux, you should be able to use this through team explorer everywhere. It also include a tf command line.
Take a look at Setting up a workspace using Team Explorer Everywhere on Linux
Should be similar on Linux.
Instead of creating the default workspace by specifying workspace name in UI setting, you could also use a Windows batch command to handle this process.
If you want to delete workspace, just add a new post build step, a cleanup command could be added to delete the previously created TFS workspace.
%TFS% workspace /delete /noprompt /collection:"{your-tfs-team-project-collection-url}" "Hudson-%JOB_NAME%;{your-domain-user-name}"
More details your could kindly refer this step-by-step tutorial Jenkins Get Source Code By Specific TFS Changeset
I want to understand the process how the build definition unshelve selected shelveset and build the code in TFS2013.
It will check whether the shelveset source code is mapped by build in the workspace, if so it will unshelve them. i want to know how internally build will evaluate the complete process.
Each build process template has a parameter called SupportedReasons. This enum is normally set to all, but you can also unselect the option ValidateShelveset to disable a shelveset build option, as shown in the picture below :
During the build pipeline, TFS build service account will running tf command to unshelve in the "Get Version" property in the advanced section of the "Parameters" tab on the "Queue Build" dialog.
It's using tf unshelve Command which will restores shelved file revisions to the workspace on build agent.
Then TFS will build source files the same as others. You could either check the build log to get more detail info, or open your build process template and click each activity to understand how the build pipeline works.
I need to check-in some files generated during a TFS 2017 vNext build.
In my old XAML build I could easily do that using the tf checkin command since the files reside in the build workspace.
In the new vNext build, The workspace owner is Project Build Service or Project Collection Build Service, even when I configure the agent to run under a different account.
Any way to perform the check-in on the build workspace? Or somehow configure who owns that workspace?
There are Add and Check in changes tasks in TFVC Build Tasks extension.
Regarding no pending changes, you need to add the files to the list of pending changes for the workspace by calling TF add command.
It's not a recommend way to check-in/ modify source code during a build pipeline. If you really want to do this, you could edit the build worspace files and use tf commands in custom/powershell task eq:
cd $env:BUILD_SOURCESDIRECTORY
$TFFile = Get-Item "C:\Program Files (x86)\Microsoft Visual Studio 1x.0\Common7\IDE\TF.exe"
$tfOutput = [string]( & $TFFile.FullName checkin /noprompt /override:"***NO_CI*** New version is $newVersion." /comment:"***NO_CI*** New version is $newVersion." 2>&1)
Another way is installing TFS Power Tool and use the Windows PowerShell Cmdlets to check in the files. Refer to this link for more details: PowerShell and TFS: The Basics and Beyond
I have created a Jenkins Job which gets code from TFS and builds the EAR at jenkins default workspace (/opt/jenkins/lib/jobs/PROJECTNAME/workspace/dist).
After the EAR is built, I need to checkin this EAR to TFS, but I didn't see any option to checkin artifacts to TFS.
If you are using TFS Plugin in Jenkins to get the code from TFS. It will create a workspace when get the code. Settings as following:
And then, you can add an "Execute Windows batch command" build step to check in files to TFS after EAR build via TF Command.
Now you'll get the files been checked in:
In the command, I check in the folder generated by the build, you can also just add the items generated by the build.
might be helpful.
Visit how to add an existing solution to tfs
Another add solution to TFS server