GoCD Command Repository

    This feature can be used anywhere you need to specify a custom command.

    • Add a new pipeline

    • Add a new stage to a pipeline

    • Add a new job to a stage

    • Add a new task to a job

    • Edit a task

    The older args style commands are not supported by this feature. Please convert them to the new syntax using the config xml editor ( Admin > Config XML ). For example:

    becomes

    1. <arg>a</arg>
    2. <arg>b</arg>
    3. <arg>c</arg>
    4. </exec>

    The default set of commands come from . This repository is maintained by the Go team. The Go server installer bundles a clone of this Git repository under <server-install-root>/db/command_repository/default. Every upgrade of Go Server will overwrite the contents of this directory with an up to date set of commands. Hence, please do not add your commands here. Instead, set up a private repository.

    Go team will continue to add (and sometimes update) commands to the repository on GitHub. If you want to make these commands available to your Go server without waiting for a new release or without upgrading your Go server, you could git pull them into <go-server-install-root>/db/command_repository/default as desired.

    Linux/Unix

    Here is a simple cron tab entry that you could add to Go service account’s cron tab to pull commands once a day.

    Windows

    On Windows, you could set up a scheduled task to run this script on a schedule.

    1. echo %date% %time% >>c:\pull-log.txt 2>&1
    2. cd "C:\Program Files (x86)\Go Server\db\command_repository\default"

    Go caches these commands with a refresh interval of 30 minutes so you may not see the results of a pull immediately in the lookup unless you hit the reload cache button under the command repository section on the server configuration admin page.

    Via API

    You may make a POST request to the path /go/api/admin/command-repo-cache/reload in order to update the command repository with the latest.

    If you want to add your own commands for look up, you should set up your own Git/Mercurial/Subversion/Perforce/TFS repository that your command authors can commit/check-in into.

    Command Repository - 图2

    From the Go server’s point of view, the command repository is just a directory under which it recursively looks for valid command.xml files. Note that directory names starting with a dot will be ignored.

    1. Command author pushes/checks-in command to corporate version control system
    2. Cron job on Go-server pulls/updates local repository/working copy in due course
    3. Go Server caches the commands to improve response time. In case of changes in the command repository, new command gets into the cache in one of the following ways:
      1. The default cache invalidation interval of 30 mins kicks in and the cache gets refreshed
      2. Go server admin clicks on the RELOAD CACHE button
      3. Go server admin uses the reload API through a cron job or otherwise to force a cache reload.

    The above screenshot resulted from the command below:

    1. <!--
    2. name: curl
    3. description: Download from a protected Url and saveToFile
    4. author: Go Team
    5. moreinfo: http://curl.haxx.se/docs/manual.html
    6. -->
    7. <exec command="curl">
    8. <arg>-o</arg>
    9. <arg>saveToFile</arg>
    10. <arg>-u</arg>
    11. <arg>user:password</arg>
    12. <arg>http://targeturl</arg>

    This is an example of valid command syntax. The command attribute is mandatory. No other attributes are valid. Zero or more arg child elements can be specified. No other child elements are allowed. One command file may only contain one command.

    When you lookup a command, the following logic is used to sort the resulting suggestions:

    1. Exact matches of name in command documentation (or filename if name missing)
    2. Partial starts-with matches of name in command documentation (or filename if name missing)
    3. Exact matches of keywords in command documentation

    Within each category, the sorting is alphabetical.

    1. fork this
    2. Clone it locally
    3. Commit and push your change
    4. Send us a pull request

    Accepted commands will be bundled into the next release.