Task Extension

Overview

GoCD supports configuring a few kinds of tasks (Nant, Ant and Rake), directly, from the configuration UI, without specifying them as a custom command. For instance, if you go to the configuration UI for a job, you’ll see something like this:

Task Extension - 图1

A task plugin allows you to extend this so that you can have other tasks available here. The plugin also allows you to control the UI, as well as the data stored for this task.

For instance, you can find the source of a sample Curl plugin, at this location. Assuming you have the plugin installed, you’ll see that the dropdown in the job configuration UI has changed to look like this:

Task Extension - 图2

When selected, the dialog box which allows you to configure details about the task looks like this:

Task Extension - 图3

In the configuration XML, the information entered for this task looks like this:

  1. <task>
  2. <pluginConfiguration id="curl.task.plugin" version="1" />
  3. <configuration>
  4. <property>
  5. <key>Url</key>
  6. <value>http://www.google.com</value>
  7. </property>
  8. <property>
  9. <key>SecureConnection</key>
  10. <value>no</value>
  11. </property>
  12. <property>
  13. <key>RequestType</key>
  14. <value>-G</value>
  15. </property>
  16. <property>
  17. <key>AdditionalOptions</key>
  18. <value />
  19. </property>
  20. </configuration>
  21. <runif status="passed" />
  22. </task>

When a build which uses the plugin runs, the output of the build looks something like this:

  1. [go] Start to execute task: Plugin with ID: curl.task.plugin.
  2. Launching command: [curl, -G, --insecure, -o, pipelines/up42/index.txt, http://www.google.com]
  3. Environment variables:
  4. Name= MAVEN_OPTS Value= -Xms256m -Xmx512m
  5. Name= GO_STAGE_COUNTER Value= 1
  6. Name= GO_REVISION_BLAH Value= cde1e03a05170b991a92a136278c3464e4f35fe7
  7. Name= GO_JOB_NAME Value= up42_job
  8. Name= EDITOR Value= vim
  9. Name= SECURITYSESSIONID Value= 186a4
  10. ... lots more environment variables ...
  11. % Total % Received % Xferd Average Speed Time Time Time Current
  12. Dload Upload Total Spent Left Speed
  13. 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
  14. 0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
  15. 100 259 100 259 0 0 122 0 0:00:02 0:00:02 --:--:-- 122

You can write a task plugin in GoCD using JSON API - Message based