Jenkins Queue Job task

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017

Use this task in a build or release pipeline to queue a job on a Jenkins server.


In Microsoft Team Foundation Server (TFS) 2018 and previous versions, run and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.



YAML snippet

# Jenkins queue job
# Queue a job on a Jenkins server
- task: JenkinsQueueJob@2
    #isMultibranchJob: # Optional
    #multibranchPipelineBranch: # Required when isMultibranchJob == True
    #captureConsole: true 
    #capturePipeline: true # Required when captureConsole == True
    #jobParameters: # Optional


Argument Description
Jenkins service connection

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

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 task 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 task 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 Jenkins 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 parameter value, e.g. specify parameterName=

Variables are supported, e.g. to define the commitId parameter 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 Azure Pipelines/TFS 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>/ 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).

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

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. Variables are available in expressions as well as scripts; see variables to learn more about how to use them. There are some predefined build and release variables you can also rely on.

Do I need an agent?

You need at least one agent to run your build or release. Get an agent for Linux, macOS, or Windows.

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

See Troubleshoot Build and Release.

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

See Agent pools.

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

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.