I am trying to use Jenkins to build my code which resides in a https://*.visualstudio.com/DefaultCollection.
I have tried to manually check the code out using a script in jenkins e.g.
tf workspace /delete JENKINS /noprompt /collection:https://*******.visualstudio.com/DefaultCollection /login:mylogin#myaccount.com,mypassword
tf workspace /new JENKINS /noprompt /collection:https://*******.visualstudio.com/DefaultCollection /permission:Private /login:mylogin#myaccount.com,mypassword
tf workfold /workspace:JENKINS /s:https://*******.visualstudio.com/DefaultCollection /map "$/MyProject" "%WORKSPACE%"
tf get /force /recursive
This runs fine from the command line but fails in Jenkins with
TF30063: You are not authorized to access
Jenkins is running as Local System Account. I have tried the plugin for jenkins which no joy either. This also failed on authentication.
Even if you have no intention of using it, I'd install and configure the TFS build controller software. This will create the authentication link between the cloud instance and the system profile. Jenkins, running in that user profile context, should then be able to issue TF commands and create workspaces.
That said, I'd also create a build service account and not use SYSTEM.
Related
I've tried to run TFS command line in the Jenkins. However, I got this message error: unable to determine the workspace. You may be able to correct this by running "tf workspaces /collection:TeamProjectCollectionUrl".
I checked the workspace and it is correct. Ex.: tf workspaces
I checked the map and it is correct. Ex: tf workfold.
I ran the get command, informing the login and password and it didn't work in the Jenkins.
I ran this command in the powershell (outside jenkins) and the cmd worked well, however, If I ran get command (call via bat and powershell) in the jenkins, It didn't work.
Why did tfs commands work well outside the Jenkins and the Jenkins didn't?
Could anyone help me?
Thank you!
You could try to specify more parameters in your command line:
tf workspaces [/owner:ownername][/computer:computername][/collection:TeamProjectCollectionUrl][workspacename][/login:username,[password]]
I've tested with parameters /collection and /login in Jenkins, got a successful result:
I am trying to trigger jenkins via TFS service hook, I want to use jenkin to extract out check in information to create a log using powershell script. I have it set up to trigger the jenkins on check in. but I can not figure out a way to parse message info sent from TFS service hook. Looking at https://github.com/jenkinsci/tfs-plugin/blob/master/README.md I can see there are few environment variables created on trigger but I want to extract some of the check in information as in username who checked in and tfs id it was checked in against etc. TFS_USERNAME only record the username of the account that is configured to access tfs in Jekins
You can use TFS REST API to get a changset on Jekins side. The API is as below:
GET http://({server:port})/DefaultCollection/_apis/tfvc/changesets/{id}?api-version=1.0
There isn't any way to extract the hooks that Jenkins received in the build trigger. However, if the Jenkins job download the latest source code to local after the job is triggered, the information you want like the user who check in the changes is already in local. You can simple run tf changeset /latest /noprompt to get this information. And you can also install TFS Power Tools and then create a powershell script to get these information via TFS Powershell Command. For example:
add-pssnapin Microsoft.TeamFoundation.PowerShell
$cs = Get-TfsChangeset -Latest
Write-Host $cs.CommitterDisplayName
Write-Host $cs.Committer
I have installed Jenkins in Unix box and I am trying to trigger a build i.e. initiating BuildDefinition present in TFS project. I am new to this so I am not sure how to trigger BuildDefinition from jenkins.
Note: I am able to checkout the source file present in TFS from jenkins. Also i installed TEE-CLC-12.0 in Jenkins Unix box.
Please help!!!
How can I report from my build scripts who the current tfs user is?
I'm setting up automated builds with TFS 2013 and VSO and I'm having workspace errors.
I'm unable to checkout files through the build script.
I'd like to know what the user is running the tf.exe command (I've already had issues with the user running the build being automatically set to a Network Service user, who has not permissions)
In any of the pre-/post-script print the USERNAME variable. In Powershell
Write-Output "Running as '$env:USERNAME"
In a batch file
echo Running as %USERNAME%
I have Perforce managing our source. I have an application that uses Perforce as the back end. I have also setup an automated test tool that runs my application and performs automated tests. I want Jenkins to trigger the test every time there is a change in the source code. However, my Jenkins instance messes up the workspace root. It creates its own workspace root and that causes my application to fail. Jenkins actually overwrites the Perforce clients workspace root. So every time I try to get Jenkins work, I have to go and edit the workspace root in Perforce and reset it to the required value. I have tried getting Jenkins to manage the workspace and clearing the option to do the same but have failed. Is there anyway that Jenkins will use my workspace (root) settings and not change it?
Jenkins 'owns' the Perforce workspace used for the build, hence it sets the root.
Your application should ideally build and run independently of its location. However, there is the 'Advanced Project Options' --> 'Use custom workspace' configuration option in Jenkins.
Jenkins must have it's own Perforce workspace separate to your own development workspace. Use the Template workspace to mirror the options or create a Manual workspace for Jenkins own use.
Please note, there are two Perforce plugins for Jenkins p4 and perforce, documentation for the p4 plugin is located here/