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.
# Jenkins queue job # Queue a job on a Jenkins server - task: JenkinsQueueJob@2 inputs: serverEndpoint: jobName: #isMultibranchJob: # Optional #multibranchPipelineBranch: # Required when isMultibranchJob == True #captureConsole: true #capturePipeline: true # Required when captureConsole == True isParameterizedJob: #jobParameters: # Optional
|Jenkins service connection||
Select the service connection for your Jenkins instance. To create one, click Manage and create a new Jenkins service connection.
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.
Select this option if the Jenkins job requires 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:
|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:
- Install the Team Foundation Server Plug-in on the Jenkins server.
- 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.
- 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).
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:
On the variables tab, add
system.debugand set it to
true. Select to allow at queue time.
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?
$(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?
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.