Build: Jenkins Queue Job

Last Update: 12/12/2016

Team Services | TFS 2017 | Previous versions (XAML builds)

Queue a job on a Jenkins server

Demands

None

Arguments

Argument Description
Jenkins service endpoint

Select the service endpoint for your Jenkins instance. To create one, click Manage and create a new Jenkins Service Endpoint.

Job name

The name of the Jenkins job to queue. This must exactly match the job name on the Jenkins server.

Capture console output and wait for completion

If selected, this step will capture the Jenkins build console output, wait for the Jenkins build to complete, and succeed/fail based on the Jenkins build result. Otherwise, once the Jenkins job is successfully queued, this step will successfully complete without waiting for the Jenkins build to run.

Capture pipeline output and wait for pipeline completion

This option is similar to capture console output except it will capture the output for the entire Jenkins pipeline, wait for completion for the entire pipeline, and succeed/fail based on the pipeline result.

Parameterized job

Select this option if the Jekins job requires parameters.

Job parameters

This option is available for parameterized jobs. Specify job parameters, one per line, in the form parameterName=parameterValue

To set a parameter to an empty value (useful for overriding a default value) leave off the paramter value, e.g. specify parameterName=

Variables are supported, e.g. to define the commitId paramter to be the git commit ID for the build, use: commitId=$(Build.SourceVersion).

Supported Jenkins parameter types are:

  • Boolean
  • String
  • Choice
  • Password

Trust server certificate

Selecting this option results in the Jenkins server's SSL certificate being trusted even if it is self-signed or cannot be validated by a Certificate Authority (CA).

Team Foundation Server Plug-in

You can use Team Foundation Server Plug-in (version 5.2.0 or newer) to automatically collect files from the Jenkins workspace and download them into the build.

To set it up:

  1. Install the Team Foundation Server Plug-in on the Jenkins server.
  2. On the Jenkins server, for each job you would like to collect results from, add the Collect results for TFS/Team Services post-build action and then configure it with one or more pairs of result type and include file pattern.
  3. On the Jenkins Queue Job build task enable the Capture console output and wait for completion to collect results from the root level job, or the Capture pipeline output and wait for pipeline completion to collect results from all pipeline jobs.

Results will be downloaded to the $(Build.StagingDirectory)/jenkinsResults/<Job Name>/team-results.zip and extracted to this location. Each set of result types collected by the plug-in, will be under the team-results directory, $(Build.StagingDirectory)/jenkinsResults/<Job Name>/team-results/<ResultType>/. This is the directory where build results can be published by downstream tasks (e.g. Publish Test Results, and Publish Code Coverage Results).

Q&A

Q: I'm having problems. How can I troubleshoot them?

A: Try this:

  1. On the variables tab, add system.debug and set it to true. Select to allow at queue time.

  2. In the explorer tab, view your completed build and click the build step to view its output.

The control options arguments described above can also be useful when you're trying to isolate a problem.

Q: How do variables work? What variables are available for me to use in the arguments?

A: $(Build.SourcesDirectory) and $(Agent.BuildDirectory) are just a few of the variables you can use. See Variables.

Do I need a build agent?

You need at least one agent to run your build. Get an agent.

I can't select a default agent queue and I can't queue my build. How do I fix this?

See queues.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.