TFS - Team Foundation Server Plugin

641 views
Skip to first unread message

Stephen Rufle

unread,
Oct 1, 2015, 4:56:17 PM10/1/15
to job-dsl-plugin
I would like to try and start adding functionality to configure TFS plugin
https://wiki.jenkins-ci.org/display/JENKINS/Team+Foundation+Server+Plugin

The way \job-dsl-plugin\job-dsl-core\src\main\groovy\javaposse\jobdsl\dsl\helpers\scm\GitContext.groovy may work.

I know a little about java, groovy, and Jenkins, but would dig if I could get a mentor. I promise to not be too needy :) I will see what I can figure out on my own.

Daniel Spilker

unread,
Oct 4, 2015, 2:50:56 PM10/4/15
to job-dsl...@googlegroups.com
I had a quick look at the TFS plugin. Unfortunately it does not use the Credentials plugin to store the password, like the Git and Subversion plugins do. It uses a password field to store an encrypted password. And that's currently not supported by the Job DSL plugin. Do you need a password for your config?

Daniel

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/40fa84a8-3bc2-469e-bc5b-869ff324ab32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Rufle

unread,
Oct 4, 2015, 4:59:22 PM10/4/15
to job-dsl-plugin
When I use the plugin I do use my username and password. Is the dsl a thin wrapper around the tags that make up a job? Would I then need to create a TFSContext object[s] that has all the tags I see in the job config.xml I see when done through jenkins?

Daniel Spilker

unread,
Oct 7, 2015, 5:54:14 AM10/7/15
to job-dsl...@googlegroups.com
The DSL has some more features than just generating the tags. In case of the TFS plugin, just wrapping the tags would not be enough because for the password field, the XML value is encrypted, e.g. for a password "foo" the XML can be <password>yVItPULx0VJj9SNfptAzVqrtvDfrlxz6jYE2hXZoMGM=</password>. So if the TFS support is implemented as a thin wrapper and a user enters a plain text password into the DSL, it would not work. Forcing a user to generate a job manually, configure the TFS plugin and copy the encrypted value from config.xml is not a good user experience. And coding plain text passwords in DSL scripts is also not a best practice.

IMHO it would be the best option to add support for the Credentials plugin to the TFS plugin, similar to the Git and Subversion plugin. With the Credentials plugin, passwords are referenced by ID, so there is no need to encrypt something or to enter plain text passwords in the DSL. If that's done, it is much easier to add DSL support for the TFS plugin.

Daniel

Stephen Rufle

unread,
Oct 7, 2015, 11:04:14 AM10/7/15
to job-dsl...@googlegroups.com
That is what I thought would be the answer :) Change the TFS plugin to conform to how the rest of the scm plugins work. For now I am using the chef Jenkins recipe (https://github.com/chef-cookbooks/jenkins) to create our job definitions. I can templateize the config.xml and have chef create the job. For the short term I can use the hashed password from the current files. The other solution for my specific situation is to transition to using a proper scm GIT :)

I will still experiment with job-dsl-plugin on my own to get the lay of the land on how to leverage it in the future.

Stephen P Rufle
sru...@gmail.com
H1:480-269-JAVA (5282)


--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/l0mDRCt4Jn0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugi...@googlegroups.com.

To post to this group, send email to job-dsl...@googlegroups.com.

Daniel Spilker

unread,
Oct 7, 2015, 11:22:56 AM10/7/15
to job-dsl...@googlegroups.com
For your scripts, you can also use a configure block, e.g.:

job('example') {
  configure { project ->
    project.remove(project / scm)
    project / scm(class: 'hudson.plugins.tfs.TeamFoundationServerScm') {
      serverUrl('foo')
      projectPath('bar')
      userName('me')
      password(hudson.util.Secret.fromString('too').encryptedValue)
    }
  }
}


Daniel

Matthew MacFarland

unread,
Nov 28, 2015, 10:56:58 AM11/28/15
to job-dsl-plugin
Thanks for posting this concrete example! This worked perfectly for my TFS configuration and saved me a lot of trial and error. In my case we use a common service account and password for most of the jobs so pasting in the encrypted password string is no trouble at all.

Peter McEvoy

unread,
Jul 27, 2016, 9:19:57 AM7/27/16
to job-dsl-plugin
The example posted did not work for me with Jenkins 2.7.1 and TFS plugin 4.1 - I was getting a NRE in the job as soon as it started:

Started by user anonymous
Building in workspace D:\JenkinsWorkspaces\DSL-Tutorial-2-Test
FATAL: null
java.lang.NullPointerException
	at hudson.plugins.tfs.TeamFoundationServerScm.getWorkspaceName(TeamFoundationServerScm.java:175)
	at hudson.plugins.tfs.TeamFoundationServerScm.checkout(TeamFoundationServerScm.java:239)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
	at hudson.model.Run.execute(Run.java:1741)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:410) 
Finished: FAILURE 

Looking at the config.xml for a job that was manually setup to use the TFS plugin, I modified the posted example to this:

    configure { project ->
        project.remove(project / scm)
        project / scm(class: 'hudson.plugins.tfs.TeamFoundationServerScm') {
            serverUrl('http://tfsserver:8080/tfs/defaultcollection')
            projectPath('$/Path/To/Src')
            userName('...')
            password(hudson.util.Secret.fromString('...').encryptedValue)
            cloakedPaths(class:'list')
            localPath('.')
            workspaceName('testing')
            useUpdate(true)
        }
    }

Of course, your milage may vary

Pete

rup vijay Singh

unread,
Apr 21, 2017, 10:31:26 AM4/21/17
to job-dsl-plugin
Hi Peter,

I want to select 'Automatic' value for Credentials field under TFS plugin.How Can i Select it?

Regards
RoopVijay

Salman Patel

unread,
May 10, 2017, 8:17:45 AM5/10/17
to job-dsl-plugin
Used the same script, but the way you passed a password doesn't hold valid for me. When I gave the same password manually in the text field, it worked.
Please help.
Reply all
Reply to author
Forward
0 new messages