Giter Club home page Giter Club logo

gocd-yaml-config-plugin's Introduction

Google Groups GitHub Discussions

gocd-yaml-config-plugin

GoCD plugin to keep pipelines and environments configuration in source-control in YAML. See this document to find out what are GoCD configuration repositories.

This is the second GoCD configuration plugin, which enhances some of shortcomings of JSON configuration plugin

  • Format is concise. Unlike JSON, there are no unnecessary quotations ", brackets {} and commas ,
  • Tries to enforce correctness where possible. By using maps instead of lists and shorter object graphs.
  • Allows to have multiple pipelines and environments in single file. But doesn't force it.
  • Comments in configuration files - YAML supports comments, so you can explain why pipeline/environment it is configured like this.

Table of contents

  1. Setup
  2. Example configuration
  3. File pattern
  4. Validation
  5. Format reference
  6. Format version
  7. Issues and questions
  8. Development
  9. License

Setup

Step 1: GoCD versions newer than 17.8.0 already have the plugin bundled. You don't need to install anything.

If you're using GoCD version older than 17.8.0, you need to install the plugin in the GoCD server. Download it from the releases page and place it on the GoCD server in plugins/external directory.

Step 2: Follow the GoCD documentation to add a new configuration repository.

You can use the example repository at: https://github.com/tomzo/gocd-yaml-config-example.git.

In your config repo (tomzo/gocd-yaml-config-example.git in this case), ensure that your GoCD yaml config is suffixed with .gocd.yaml. Any file ending in .gocd.yaml is picked up by the plugin. Give it a minute or so for the polling to happen. Once that happens, you should see your pipeline(s) on your dashboard.

Example

More examples are in test resources.

#ci.gocd.yaml
format_version: 9
environments:
  testing:
    environment_variables:
      DEPLOYMENT: testing
    secure_variables:
      ENV_PASSWORD: "s&Du#@$xsSa"
    pipelines:
      - example-deploy-testing
      - build-testing
pipelines:
  mypipe1: # definition of mypipe1 pipeline
    group: mygroup # note that the group name can contain only of alphanumeric & underscore characters
    display_order: 10
    label_template: "${mygit[:8]}"
    lock_behavior: none
    parameters: # list of parameters that can be configured for a pipeline
      param1: value1
    materials:
      mygit: # this is the name of material, the name can contain only of alphanumeric & underscore characters
        # keyword git says about type of material and url at once
        git: https://my.example.org/mygit.git
        branch: ci
      myupstream: # this name does not matter, but there should be no 2 materials with the same name
        # type is optional here, material type is implied based on presence of pipeline and stage fields
        # type: dependency
        pipeline: pipe2
        stage: test
    stages: # list of stages in order
      - build: # name of stage
          clean_workspace: true
          jobs:
            csharp: # name of the job
              resources:
               - net45
              artifacts:
               - build:
                   source: bin/
                   destination: build
               - test:
                   source: tests/
                   destination: test-reports/
               - test:
                   source: coverage.xml
              tabs:
                report: test-reports/index.html
              tasks: # ordered list of tasks to execute in job csharp
               - fetch:
                   pipeline: pipe2
                   stage: build
                   job: test
                   source: test-bin/
                   destination: bin/
               - exec: # indicates type of task
                   command: make
                   arguments:
                    - "VERBOSE=true"
               # shorthand for script-executor plugin
               - script: ./build.sh ci

File pattern

The default pattern is **/*.gocd.yaml,**/*.gocd.yml, which will recursively search the entire repository for all files ending with .gocd.yaml or .gocd.yml.

You can set a custom file pattern per configuration repository using the GoCD configuration UI: yaml pattern config

Or in the config XML using <configuration>:

<config-repos>
  <config-repo pluginId="yaml.config.plugin" id="repo1">
    <git url="https://github.com/tomzo/gocd-yaml-config-example.git" />
    <configuration>
      <property>
        <key>file_pattern</key>
        <!-- comma-separate multiple patterns -->
        <value>pipelines/build/*.yml,pipelines/lint/*.yml</value>
      </property>
    </configuration>
  </config-repo>
</config-repos>

Validation

You can validate if proposed GoCD YAML changes will be accepted by the server. Currently, 2 options are available:

Validation using CLI

You may find this introductory blog post useful.

There is an ongoing effort to allow in-depth validation of configuration before pushing configuration to the source control. This is provided by GoCD's preflight API and gocd-cli.

You have several options to configure validation tools on your workstation:

Either way you'll have gocd binary in your PATH or inside the docker container.

Syntax validation

This will check general validity of the yaml file, without talking to the GoCD server:

gocd configrepo syntax --yaml pipeline.gocd.yaml

Preflight validation

This command will parse and submit your yaml file to the configured GoCD server.

gocd configrepo preflight --yaml -r dotnet-dojo pipeline.gocd.yaml

Where -r is the configuration repository id, which you have earlier configured on GoCD server. You can check it on config repos page of your GoCD server, at /go/admin/config_repos. It is in the upper left corner of each config repo. config repo id

For new repositories, when you haven't added config repo to the server yet, you can also check if it is correct, just skip the -r argument.

gocd configrepo preflight --yaml pipeline.gocd.yaml

Format reference

See official GoCD XML configuration reference for details about each element. Below is a reference of format supported by this plugin. Feel free to improve it!

  1. Format version
  2. Environment
  3. Environment variables
  4. Parameters
  5. Pipeline
  6. Stage
  7. Job
  8. Tasks
  9. Materials
  10. Secure variables
  11. YAML Aliases

Format version

Please note that it is now recommended to declare format_version in each gocd.yaml file, consistent across all your files.

GoCD server version from 20.8.0 and beyond

Supports format_version value of 10. This version removes usage of blacklist/whitelist keywords in favour of includes/ignore. This is done in a backwards compatible way - you can upgrade the server and plugin first, and update the format_version to 10 after. Just replace whitelist by includes, and blacklist by ignore.

Additionally, plugin is also "forwards compatible" since version 0.13.0. If you can't upgrade GoCD to 20.8.0, but want to migrate from blacklist/whitelist to includes/ignore, you can upgrade the plugin and keep the format_version that you are using. Plugin will migrate keywords under the hood, while your YAML can use includes/ignore.

Using a newer format_version includes all the behavior of the previous versions too.

format_version: 10
pipelines:
  ...
environments:

GoCD server version from 19.10.0 and beyond

Supports format_version value of 9. In this version, support of ignore_for_scheduling for dependency materials has been added. Setting this attribute will skip scheduling the pipeline when the dependency material has changed.

Using a newer format_version includes all the behavior of the previous versions too.

GoCD server version from 19.9.0 and beyond

Supports format_version value of 7 and 8. In version 7, support for properties has been removed. In version 8, support for mingle as a tracking tool has been removed.

Using a newer format_version includes all the behavior of the previous versions too.

GoCD server version from 19.8.0 and beyond

Supports format_version value of 6. In this version, support of allow_only_on_success attribute for approval in stage has been added. Setting this attribute to true will allow the stage to be manually triggered only if the previous stage has passed successfully.

Using a newer format_version includes all the behavior of the previous versions too.

GoCD server version from 19.4.0 to 19.7.0

Supports format_version value of 5. In this version, support of username and encrypted_password for git and hg material has been added. In addition to that, hg will also support branch attribute.

Using a newer format_version includes all the behavior of the previous versions too.

GoCD server version 19.3.0

Supports format_version value of 4. In this version, support has been added to control the display order of pipelines.

This server version also supports format_version of 3 and 2. Using a newer format_version includes all the behavior of the previous versions too.

GoCD server version from 18.7.0 to 19.2.0

Supports format_version value of 3. In this version fetch artifact format was changed to include artifact_origin.

This server version also supports format_version of 2. Using a newer format_version includes all the behavior of the previous versions too.

GoCD server version from 17.12.0 to 18.6.0

Supports format_version value of 2. In this version pipeline locking behavior was changed.

GoCD server version up to 17.11.0

Supports format_version value of 1. This is the initial version.

Pipeline

A minimal pipeline configuration must contain:

  • pipeline name - as a key in hash
  • materials - a hash
  • stages - a list or a template - as a key in hash
mypipe:
  group: mygroup
  materials:
    mygit:
      git: http://example.com/mygit.git
  stages:
    - build:
        jobs:
          build:
            tasks:
             - exec:
                 command: make

All elements available on a pipeline object are:

pipe2:
  group: group1
  label_template: "foo-1.0-${COUNT}"
  lock_behavior: none
  tracking_tool:
    link: "http://your-trackingtool/yourproject/${ID}"
    regex: "evo-(\\d+)"
  timer:
    spec: "0 15 10 * * ? *"
  environment_variables:
    DEPLOYMENT: testing
  secure_variables:
    ENV_PASSWORD: "s&Du#@$xsSa"
  materials:
    ...
  stages:
    ...

Referencing an existing template in a pipeline:

mypipe:
  group: group1
  label_template: "foo-1.0-${COUNT}"
  lock_behavior: none
  parameters:
    param1: value
  materials:
    mygit:
      git: http://example.com/mygit.git
  template: template1

Please note:

  • Pipeline declares a group to which it belongs

When format_version is 4 (see above), the order of display of pipelines on the GoCD dashboard can be influenced by setting the display_order property.

  • This is an integer property and the pipelines in a pipeline group will be ordered by this value.
  • The default value for this property is -1.
  • Pipelines defined in GoCD's config XML will also default to -1.
  • If multiple pipelines have the same display_order value, their order relative to each other will be indeterminate.
mypipeline1:
  group: group1
  display_order: 10

mypipeline2:
  group: group1
  display_order: -10

In the above example, since both pipelines are in the same group, pipeline2 will be shown ahead of pipeline1. If any pipelines are defined in the GoCD config XML, then they will appear in between these two pipelines.

Tracking tool

tracking_tool:
  link: "http://your-trackingtool/yourproject/${ID}"
  regex: "evo-(\\d+)"

Timer

timer:
  spec: "0 15 10 * * ? *"
  only_on_changes: yes

See Quartz about writing cron-like schedules.

Pipeline locking

For GoCD >= 17.12 and format_version: 2 and above:

lock_behavior: none

Where lock_behavior is defined as in GoCD documentation can be one of:

  • lockOnFailure - same as locking: true
  • unlockWhenFinished
  • none - same locking: false

For GoCD < 17.12 and format_version: 1:

locking: on

Where locking is a boolean.

Stage

A minimal stage must contain jobs: element or tasks: in single-job stage case.

build:
  jobs:
    firstJob:
      ...
    secondJob:
      ...

A custom stage:

test:
  fetch_materials: yes
  keep_artifacts: yes
  clean_workspace: yes
  approval:
    type: manual
    roles:
      - manager
    users:
      - john
  environment_variables:
    TEST_NUM: 1
  secure_variables:
    PASSWORD: "!@ESsdD323#sdu"
  jobs:
    one:
      ...
    two:
      ...
  • When keep_artifacts is set to true GoCD will never delete artifacts in this stage. This is equivalent of XML's artifactCleanupProhibited. By default this is false.

Approval

Stage can have approval, which is success by default. There are 2 ways to declare approval:

approval: manual

If you need to set associated users or roles:

approval:
  type: manual
  allow_only_on_success: true
  roles:
    - manager
  users:
    - john

You can set allow_only_on_success to allow manual trigger only if the previous stage run is successful. The default value is false.

Job

Job is a hash starting with jobs name:

test:
  timeout: 5
  run_instances: 7
  environment_variables:
    LD_LIBRARY_PATH: .
  tabs:
    test: results.xml
  resources:
    - linux
  artifacts:
    - test:
        source: src
        destination: dest
    - build:
        source: bin
    - external:
        id: docker-release-candidate
        store_id: dockerhub
        configuration:
          options:
            Image: gocd/gocd-demo
            Tag: v${GO_PIPELINE_LABEL}
          secure_options:
            some_secure_property: "!@ESsdD323#sdu"
  tasks:
    ...

Note: timeout is added since 0.2.0 version of yaml plugin

Elastic agent profile id

Job configuration may define elastic agents profile id, as such:

elastic_profile_id: "docker.unit-test"

It MUST NOT be specified along with resources. Available in GoCD server since v16.12.0, yaml plugin 0.4.0.

Artifacts

There are 3 types of artifacts recognized by GoCD. Build and Test artifacts are stored on the GoCD server. The source and the destination of the artifact that should be stored on the GoCD server must be specified.

Build

- build:
    source: bin
    destination: binaries

Test

- test:
    source: reports
    destination: test-reports

External

Artifacts of type external are stored in an artifact store outside of GoCD. The external artifact store's configuration must be created in the main GoCD config. Support for external artifact store config to be checked in as yaml is not available. The external artifact store is referenced by the store_id. The build specific artifact details that the artifact plugin needs to publish the artifact is provided as configuration.

- external:
    id: docker-release-candidate
    store_id: dockerhub
    configuration:
      options:
        Image: gocd/gocd-demo
        Tag: v${GO_PIPELINE_LABEL}
      secure_options:
        some_secure_property: "!@ESsdD323#sdu"

S3 plugin 2.x example usage:

- external:
    id: pkg
    store_id: s3-eu-west-1
    configuration:
      options:
        Source: installers/target/
        Destination: ${GO_ARTIFACT_LOCATOR}

Run many instances

Part of job object can be number of job to runs:

run_instances: 7

Or to run on all agents:

run_instances: all

Tabs

Tabs are a hash with <tab-name>: <path> pairs. Path should exist in GoCD servers artifacts.

tabs:
  tests: test-reports/index.html
  gauge: functional-reports/index.html

Property

DEPRECATION NOTICE: Since GoCD version 19.9 and format_version 7, properties are no longer supported

Job can have properties, declared as a hash:

properties:
  cov1: # this is the name of property
    source: test.xml
    xpath: "substring-before(//report/data/all/coverage[starts-with(@type,\u0027class\u0027)]/@value, \u0027%\u0027)"
  performance.ind1.mbps:
    source: PerfTestReport.xml
    xpath: "//PerformanceSuiteReport/WriteOnly/MBps"

Single job stage

A common use case is that stage has only one job. This plugin provides a shorthand to declared such stages - just omit the jobs: and job name from configuration tree. You can then declare job and stage options on the same (stage) level:

stages:
  - build:
      approval: manual
      resources:
        - cpp
      tasks:
       - exec:
           command: make

Above configuration declares build stage with build job which executes make task.

Materials

Git

Minimal configuration of a git pipeline material:

  • material name is mygit
  • git repository url is http://example.com/mygit.git
mygit:
  git: http://example.com/mygit.git

Above can be also written more explicitly:

mygit:
  type: git
  url: http://example.com/mygit.git

More customized git material is possible:

gitMaterial1:
  git: "https://my.git.repository.com"
  branch: feature12
  ignore:
    - externals/**/*.*
    - tools/**/*.*
# For GoCD < 20.8.0 or plugin version < 0.13.0, you need to use blacklist instead of ignore:
  blacklist:
    - externals/**/*.*
    - tools/**/*.*
  destination: dir1
  auto_update: false
  shallow_clone: true

Since GoCD >= 16.7.0 includes is also supported, you can specify includes instead of ignore, as such

gitMaterial1:
  git: "[email protected]"
  branch: "feature12"
  includes:
    - src/**/*.*
# For GoCD < 20.8.0 or plugin version < 0.13.0, you need to use whitelist instead:
  whitelist:
    - src/**/*.*

For GoCD >= 19.4.0 and format_version: 5 and above:

You are advised to utilize username and encrypted_password for passing in material credentials as:

gitMaterial1:
  git: "https://my.git.repository.com"
  branch: feature12
  username: my_username
  encrypted_password: encrypted_value
  • Instead of encrypted_password you may specify password but encrypted_password makes more sense considering that the value is stored in SCM.
  • Specifying credentials both in attributes and url will result in a validation error e.g.
      INVALID MERGED CONFIGURATION
      Number of errors: 1+
      1. Ambiguous credentials, must be provided either in URL or as attributes.;;
      - For Config Repo: https://your.config.repo.url at cbb047d78c239ab23b9565099e800c6fe4cc0anc
    

For details about each option, see GoCD XML reference

svnMaterial1:
  svn: "http://svn"
  username: "user1"
  encrypted_password: "encrypted_value"
  check_externals: true
  ignore:
    - tools
    - lib
# For GoCD < 20.8.0 or plugin version < 0.13.0, you need to use blacklist instead of ignore:
  blacklist:
    - tools
    - lib
  destination: destDir1
  auto_update: false

Instead of encrypted_password you can specify password.

Hg

hgMaterial1:
  hg: repos/myhg
  ignore:
    - externals
    - tools
# For GoCD < 20.8.0 or plugin version < 0.13.0, you need to use blacklist instead of ignore:
  blacklist:
    - externals
    - tools
  destination: dir1
  auto_update: false
  username: my_username
  encrypted_password: encrypted_value
  branch: feature

For GoCD >= 19.4.0 and format_version: 5 and above:

You are advised to utilize username and encrypted_password for passing in material credentials as:

hgMaterial1:
  hg: repos/myhg
  username: my_username
  encrypted_password: encrypted_value
  • Instead of encrypted_password you may specify password but encrypted_password makes more sense considering that the value is stored in SCM.
  • Specifying credentials both in attributes and url will result in a validation error e.g.
      INVALID MERGED CONFIGURATION
      Number of errors: 1+
      1. Ambiguous credentials, must be provided either in URL or as attributes.;;
      - For Config Repo: https://your.config.repo.url at cbb047d78c239ab23b9565099e800c6fe4cc0anc
    

In addition to that, you can also leverage branch attribute to specify the branch for material

hgMaterial1:
  hg: repos/myhg
  branch: feature
p4Material1:
  p4: "host.domain.com:12345"
  username: johndoe
  encrypted_password: encrypted_value
  use_tickets: false
  view: |
    //depot/external... //ws/external...
    //depot/tools... //ws/external...
  ignore:
    - externals
    - tools
# For GoCD < 20.8.0 or plugin version < 0.13.0, you need to use blacklist instead of ignore:
  blacklist:
    - externals
    - tools
  auto_update: false

Instead of encrypted_password you can specify password.

Tfs

TODO: - not supported by yaml plugin yet

Pluggable

myPluggableGit:
  scm: someScmGitRepositoryId
  destination: destinationDir
  ignore:
    - dir1
    - dir2
# For GoCD < 20.8.0 or plugin version < 0.13.0, you need to use blacklist instead of ignore:
  blacklist:
    - dir1
    - dir2

Since GoCD >= 19.2.0 defining new pluggable materials that are not defined in the GoCD server is supported.

myPluggableGit:
  plugin_configuration:
    id: plugin_Id
    version: 1 #plugin version
  options:
    url: [email protected]:tomzo/gocd-yaml-config-plugin.git
  secure_options:
    password: "encrypted_value"
  destination: destinationDir
  ignore:
    - dir1
    - dir2
# For GoCD < 20.8.0 or plugin version < 0.13.0, you need to use blacklist instead of ignore:
  blacklist:
    - dir1
    - dir2

Configrepo

This is a convenience for shorter and more consistent material declaration. When configuration repository is the same as one of pipeline materials, then you usually need to repeat definitions in XML and in JSON, for example:

materials:
  foo:
    git: "https://github.com/tomzo/gocd-json-config-example.git",
    branch: ci

And in server XML:

<config-repos>
   <config-repo pluginId="yaml.config.plugin" id="repo1">
     <git url="https://github.com/tomzo/gocd-json-config-example.git" branch="ci" />
   </config-repo>
</config-repos>

Notice that url and branch is repeated. This is inconvenient in case when you move repository, because it requires 2 updates, in code and in server XML.

Using configrepo material type, above repetition can be avoided, last example can be refactored into:

materials:
  foo:
    type: configrepo

Server interprets configrepo material in this way:

Clone the material configuration of the repository we are parsing as is in XML and replace name, destination and filters (includes/ignore), then use the modified clone in place of configrepo material.

Dependency

To add a dependency on another pipeline stage:

mydependency:
  pipeline: upstream-pipeline-1
  stage: test
  ignore_for_scheduling: false

Note: mydependency is the name of material - it must be unique

Package

myapt:
  package: apt-repo-id

Tasks

Every task is a hash starting with its type. Type can be exec, ant, nant, rake, fetch, plugin or script.

<type>:
  <task-prop1>: <prop1-value>

Optionally any task can have run_if and on_cancel.

  • run_if is a string. Valid values are passed, failed, any
  • on_cancel is a task object. Same rules apply as to tasks described on this page. See rake example.

Exec

exec:
  run_if: any
  working_directory: dir
  command: make
  arguments:
   - -j3
   - docs
   - install

Ant

ant:
  build_file: mybuild.xml
  target: compile
  run_if: passed

Nant

nant:
  run_if: passed
  working_directory: "script/build/123"
  build_file: FilePath
  target: Build
  nant_path: NantExe

Rake

A minimal rake task with default values is very short

rake:

A complete rake example:

rake:
  run_if: passed
  working_directory: sample-project
  build_file: SomeRakefile
  target: build
  on_cancel:
    rake:
      working_directory: sample-project
      build_file: CancelRakefile
      target: cancel

Fetch

Fetch artifact from the GoCD server

fetch:
  run_if: any
  artifact_origin: gocd # default value
  pipeline: pipe2
  stage: upstream_stage
  job: upstream_job
  is_file: yes
  source: result
  destination: test
  • artifact_origin if not specified then, defaults to gocd, which is consistent with previous format_version 1 and 2.
  • pipeline if not specified, then defaults to current pipeline.

Fetch artifact from an external artifact store

fetch:
  run_if: any
  artifact_origin: external
  pipeline: pipe2
  stage: upstream_stage
  job: upstream_job
  artifact_id: upstream_artifact_id
  configuration:
    options:
      DestOnAgent: foo
    secure_options:
      some_secure_property: "!@ESsdD323#sdu"

S3 plugin 2.x example usage:

- fetch:
    artifact_origin: external
    stage: plan
    job: plan
    artifact_id: plan
    configuration:
      options:
        IsFile: true
        Destination: terraform
        Source: deployment.tfplan

Plugin

plugin:
  options:
    ConverterType: jsunit
  secure_options:
    password: "ssd#%fFS*!Esx"
  run_if: failed
  configuration:
    id: xunit.converter.task.plugin
    version: 1

Script

Because script-executor plugin requires quite a lot of boiler-plate configuration there is a shorthand for defining tasks with it:

script: ./build.sh compile

Above is equivalent of

plugin:
  options:
    script: ./build.sh compile
  configuration:
    id: script-executor
    version: 1

You can declare multi-line scripts too:

script: |
  ./build.sh compile
  make test

Above executes a 2-line script:

./build.sh compile
make test

If you want to execute a single long line script, but break it into multiple lines in YAML, you can do this with > as such:

script: >
  ./build.sh compile &&
  make test

Above executes a single line script:

./build.sh compile && make test

Environment

NOTE: The agents should be a guid, which is currently impossible to get for user

testing:
  environment_variables:
    DEPLOYMENT: testing
  secure_variables:
    ENV_PASSWORD: "s&Du#@$xsSa"
  pipelines:
    - example-deploy-testing
    - build-testing
  agents:
    - 123

Environment variables

Environment variables can be declared in Environments, Pipelines, Stages and Jobs.

In YAML you have 2 keywords for secure (encrypted) variables and standard variables.

environment_variables:
  DEPLOYMENT: testing
  FOO: bar
secure_variables:
  # this value is encrypted by Go's private key (Note in 16.7.0 there is no easy way to obtain such value yet)
  MY_PASSWORD: "s&Du#@$xsSa"

Parameters

Parameters can be declared at the pipeline level.

parameters:
  param1: value1
  production: no

To generate an encrypted value

For versions of GoCD >= 17.1:

See the encryption API.

For versions of GoCD <= 16.12:

There is no easy way to generate obtain encrypted value from GoServer, alternatively you can login into go-server and execute the following command to generate encrypted value

sudo -u go bash -c 'echo -n 'YOUR-INPUT' | openssl enc -des-cbc -a -iv 0 -K $(cat /etc/go/cipher)'

Boolean values

Among all configuration elements there are boolean values, which can be defined using any of the keywords below (as in yaml specs):

  • true - y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON
  • false - n|N|no|No|NO|false|False|FALSE|off|Off|OFF

YAML Aliases

YAML Aliases (specification) are supported and provide a way to avoid duplication.

Aliases can be defined anywhere in the configuration as long as they are valid configuration elements.

- exec:
  command: make
  arguments:
   - clean
   - &verbose_arg "VERBOSE=true" # define the alias
- exec:
  command: make
  arguments:
   - world
   - *verbose_arg # use the alias

There is also a dedicated top-level common section which allows you to have all aliases in one place and where you don't need to worry about correct placement within the configuration.

format_version: 4
common:
  verbose_arg: &verbose_arg "VERBOSE=true"
  build_tasks: &build_tasks
    - exec:
        command: make
        arguments:
         - clean
    - exec:
        command: make
        arguments:
         - world
pipelines:
  pipe1:
    stages:
      - build:
          jobs:
            build:
              tasks: *build_tasks
            test:
              tasks:
               - *build_tasks # task list aliases can also be mixed with additional tasks in the same job
               - exec:
                   command: make
                   arguments:
                    - test

Similarly stages can be re-used:

format_version: 4
common:
  build_stages: &build_stages
    - stage1:
        jobs:
          # ...
    - stage2:
        jobs:
          # ...

pipelines:
  pipeline_one:
    stages: *build_stages

  pipeline_two:
    stages:
      - *build_stages
      - stage3:
        jobs:
          # ...

Issues and questions

  • If you have questions on usage, please ask them on the GoCD Google Groups forum or GitHub Discussions.
  • If you think there is a bug, or you have an idea for a feature and you are not sure if it's plugin's or GoCD fault/responsibity, please ask on the chat first too.

Please note this brief overview of what is done by the plugin:

  • parsing yaml into json when GoCD server asks for it.

And this is done by the GoCD server:

  • complex logic merging multiple config repo sources and XML
  • validation of pipelines/stages/jobs/tasks domain
  • any UI rendering

Development

Environment setup

To build and test this plugin, you'll need java jdk >= 11.

If you have local java environment, then you may run all tests and create a ready to use jar with:

./gradlew test jar

Building with docker and dojo

You don't need to setup java on your host, if you are fine with using docker and Dojo. This is actually how our GoCD builds the plugin:

dojo "gradle test jar"

Assuming you already have a working docker, On OSX, you can install with homebrew:

brew install kudulab/homebrew-dojo-osx/dojo

A manual install is another option:

version="0.9.0"
# on Linux:
wget -O /tmp/dojo https://github.com/kudulab/dojo/releases/download/${version}/dojo_linux_amd64
# or on Darwin:
# wget -O /tmp/dojo https://github.com/kudulab/dojo/releases/download/${version}/dojo_darwin_amd64
chmod +x /tmp/dojo
mv /tmp/dojo /usr/bin/dojo

Then enter a docker container with java and gradle pre-installed, by running following command at the root of the project:

dojo

Versioning

We use semantic versioning.

If you are submitting a new feature or patch, please bump the version in build.gradle.

Tests structure

There are examples of yaml partials and their resulting json to be sent to GoCD server. If something is not working right we can always add a new case covering exact yaml that user has and json that we expect on server side.

License

Copyright 2020 Tomasz Sฤ™tkowski

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

gocd-yaml-config-plugin's People

Contributors

arvindsv avatar atbentley avatar bdpiprava avatar chadlwilson avatar danjou avatar davified avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar drewsonne avatar ganeshspatil avatar gradle-update-robot avatar ibnc avatar ihr avatar jskswamy avatar ketan avatar kierarad avatar kritika-singh3 avatar maheshp avatar marques-work avatar michaelbannister avatar psyked avatar sandro-h avatar sanjusoftware avatar tedder avatar tomzo avatar varshavaradarajan avatar vrushaliwaykole avatar xmik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gocd-yaml-config-plugin's Issues

Create yaml pipeline as initially paused

  1. When creating pipeline from GoCD GUI, the initial state of the pipeline is paused.
  2. When creating the pipeline directly into config xml in GoCD GUI config xml field, the initial state of the pipeline is active.
  3. When creating the pipeline as yaml and then pushed into git config-repo, the initial state is also active. Is there some attribute that can make the pipeline initial state as paused?

how to use a file as an artifact?

Here's the scenario:

I have a pipeline which generates an artifact 'image_ref' like following:

pipelines:
  build-solr-collection-deployer-image1: # definition of mypipe1 pipeline
    group: APISolrCollectionDeployer
    materials:
      mygit: # this is the name of material, the name can contain only of alphanumeric & underscore characters
        # keyword git says about type of material and url at once
        git: http://githuben.intranet.mckinsey.com/Enterprise-Architecture/solr_collection_deployer.git
        branch: master
    stages: # list of stages in order
      - build-image: # name of stage
          clean_workspace: true
          jobs:
            build-image: # name of the job
              artifacts:
               - build:
                   source: image_ref
              tasks:
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker build --no-cache -t x.x.x.x:5000/mck/solr_collection_deployer:latest -t x.x.x.x:5000/mck/solr_collection_deployer:${GO_REVISION_MYGIT} ."
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker push x.x.x.x:5000/mck/solr_collection_deployer:latest"
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker push x.x.x.x:5000/mck/solr_collection_deployer:${GO_REVISION_MYGIT}"
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "echo \"x.x.x.x:5000/mck/solr_collection_deployer:${GO_REVISION_MYGIT}\" | tee image_ref"

I use this artifact within another pipeline like following:

pipelines:
  geo-offices-api-sandbox1:
    group: APIGeoOfficesSolrCollection
    materials:
      upstream:
        type: dependency
        pipeline: build-solr-collection-deployer-image
        stage: build-image
      mygit: # this is the name of material, the name can contain only of alphanumeric & underscore characters
        # keyword git says about type of material and url at once
        git: http://githuben.intranet.mckinsey.com/Enterprise-Architecture/geo_offices_solr_collection.git
        branch: master
    stages: # list of stages in order
      - deploy: # name of stage
          clean_workspace: true
          jobs:
            deploy-solr-collection: # name of the job
              tasks:
               - fetch: # indicates type of task
                   pipeline: build-solr-collection-deployer-image
                   source: image_ref
                   stage: build-image
                   job: build-image
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker run -e HOST=sandbox -e COLLECTION=geo_offices -e GIT_REPO=http://githuben.intranet.mckinsey.com/Enterprise-Architecture/geo_offices_solr_collection.git `cat image_ref`"

however, the problem is that when go-server runs this build, it this to download this artifact as a "zip" file rather than a normal file. While I was doign the same in xml, it was working fine. The xml pipeline for the above is as below:

<pipelines group="APIGeoOfficesSolrCollection">
  <pipeline name="geo-offices-api-sandbox">
    <materials>
      <git url="http://githuben.intranet.mckinsey.com/Enterprise-Architecture/geo_offices_solr_collection.git" />
      <pipeline pipelineName="build-solr-collection-deployer-image" stageName="build-image" materialName="build-solr-collection-deployer-image" />
    </materials>
    <stage name="deploy">
      <jobs>
        <job name="deploy-solr-collection">
          <tasks>
            <fetchartifact pipeline="build-solr-collection-deployer-image" stage="build-image" job="build-image" srcfile="image_ref">
              <runif status="passed" />
            </fetchartifact>
            <exec command="bash">
              <arg>-c</arg>
              <arg>docker run -e HOST=sandbox -e COLLECTION=geo_offices -e GIT_REPO=http://githuben.intranet.mckinsey.com/Enterprise-Architecture/geo_offices_solr_collection.git `cat image_ref`</arg>
              <runif status="passed" />
            </exec>
          </tasks>
        </job>
      </jobs>
    </stage>
  </pipeline>
</pipelines>

so, essentially the question is how do I specify that the source is just a file and not zip??

improve error message when group exists but with different letter capitalization

Given a gocd server
And a pipeline A is added in group Group1
When a pipeline B is added in group group1
Then Group1 should contain pipelines: A, B

However, right now, when pipeline B is read by the plugin, the error presented in GoCD server "Error" section (the red button in top right corner), shows:

2+ errors :: Group with name 'infrastructure' already exists;; Group with name 'infrastructure' already exists;; - Config-Repo: ssh://[email protected]:5522/infrastructure/gitlab-gocd-bridge.git at 0ca596f5d7a1c3860faabec41ae3b17f87f105a6

Problem: group name is case-sensitive, but the error message doesn't say anything about that.

add support for config-repos

Hi,

can we add support for the tags config-repos and config-repo so that we can defined new repositories outside the main server xml?

Change "plugin" to "pluginId"

Type:

  • Bug Report

Description

config-repo tag under config-xml has changed to contain "pluginId" attribute instead of "plugin"

Current Result

<config-repos>
   <config-repo plugin="json.config.plugin">
     <git url="https://github.com/tomzo/gocd-json-config-example.git" />
   </config-repo>
</config-repos>

Expected Result

<config-repos>
   <config-repo pluginId="json.config.plugin" id="repo1">
     <git url="https://github.com/tomzo/gocd-json-config-example.git" />
   </config-repo>
</config-repos>

More information

Agent uuid not accepted in yaml Environment settings

Hi, I would like to use Environment setting in gocd-yaml, having agent uuid (GUID) defined. The Readme of gocd-yaml-config-plugin tells that user cannot find GUID? I found GUID file from agent disk /godata/config/guid.txt, having this kind of content "f146f42d-b741-4fc2-9dcd-36abb407xxyy".

However the GUID I found is not accepted by Go: "Environment 'installations' has an invalid agent uuid 'f146f42d-b741-4fc2-9dcd-36abb407...". Also it is not possible to set agent in GoCD UI in Environment section, GoCD says "There are no agents available".

Currently I don't know what is the root problem here, but would it be possible to get this issue fixed somehow?

Clip from the Readme.md:
"Environment

NOTE: The agents should be a guid, which is currently impossible to get for user

testing:
environment_variables:
DEPLOYMENT: testing
secure_variables:
ENV_PASSWORD: "s&Du#@$xsSa"
pipelines:
- example-deploy-testing
- build-testing
agents:
- 123"

how to add 2 'upstream' piplines as dependencies?

I have the following pipelines created using gocd admin UI (which ran successfully):

<pipelines group="APIPersonSolrCollection">
  <pipeline name="persons-api-sandbox">
    <materials>
      <git url="http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection" />
      <pipeline pipelineName="build-solr-collection-deployer-image" stageName="build-image" materialName="build-solr-collection-deployer-image" />
    </materials>
    <stage name="deploy">
      <jobs>
        <job name="deploy-solr-collection">
          <tasks>
            <fetchartifact pipeline="build-solr-collection-deployer-image" stage="build-image" job="build-image" srcfile="image_ref">
              <runif status="passed" />
            </fetchartifact>
            <exec command="bash">
              <arg>-c</arg>
              <arg>docker run -e HOST=sandbox -e COLLECTION=api_persons -e GIT_REPO=http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection.git `cat image_ref`</arg>
              <runif status="passed" />
            </exec>
          </tasks>
        </job>
      </jobs>
    </stage>
  </pipeline>
  <pipeline name="persons-api-development">
    <materials>
      <pipeline pipelineName="build-solr-collection-deployer-image" stageName="build-image" materialName="build-solr-collection-deployer-image" />
      <pipeline pipelineName="persons-api-sandbox" stageName="deploy" materialName="sandbox-deployment-successful" />
    </materials>
    <stage name="deploy">
      <jobs>
        <job name="deploy-solr-collection-to-dev-servers">
          <tasks>
            <fetchartifact pipeline="build-solr-collection-deployer-image" stage="build-image" job="build-image" srcfile="image_ref">
              <runif status="passed" />
            </fetchartifact>
            <exec command="bash">
              <arg>-c</arg>
              <arg>docker run -e HOST=development -e COLLECTION=api_persons -e GIT_REPO=http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection.git `cat image_ref`</arg>
              <runif status="passed" />
            </exec>
          </tasks>
        </job>
      </jobs>
    </stage>
  </pipeline>
</pipelines>

while moving it to the github repo, I did the following YAML conversion:

#ci.gocd.yaml
pipelines:
  persons-api-sandbox:
    group: APIPersonSolrCollection
    materials:
      upstream:
        type: dependency
        pipeline: build-solr-collection-deployer-image
        stage: build-image
      repo: # this is the name of material, the name can contain only of alphanumeric & underscore characters
        # keyword git says about type of material and url at once
        git: http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection.git
        branch: master
    stages: # list of stages in order
      - deploy: # name of stage
          clean_workspace: true
          jobs:
            deploy-solr-collection: # name of the job
              tasks:
               - fetch: # indicates type of task
                   pipeline: build-solr-collection-deployer-image
                   source: image_ref
                   stage: build-image
                   job: build-image
                   is_file: yes
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker run -e HOST=sandbox -e COLLECTION=api_persons -e GIT_REPO=http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection.git `cat image_ref`"
  persons-api-development:
    group: APIPersonSolrCollection
    materials:
      upstream:
        type: dependency
        pipeline: build-solr-collection-deployer-image
        stage: build-image
      upstream:
        type: dependency
        pipeline: persons-api-sandbox
        stage: deploy
    stages: # list of stages in order
      - deploy: # name of stage
          clean_workspace: true
          jobs:
            deploy-solr-collection-to-dev-servers: # name of the job
              tasks:
               - fetch: # indicates type of task
                   pipeline: build-solr-collection-deployer-image
                   source: image_ref
                   stage: build-image
                   job: build-image
                   is_file: yes
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker run -e HOST=development -e COLLECTION=api_persons -e GIT_REPO=http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection.git `cat image_ref`"

When GOCD runs this configuration, the first pipeline 'persons-api-sandbox' passes successfully however the second pipeline 'persons-api-development' fails with the following error.

1+ errors :: Pipeline "persons-api-development" tries to fetch artifact from pipeline "build-solr-collection-deployer-image" which is not an upstream pipeline;; - Config-Repo: http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection.git

FYI: in case you are wondering, 'build-solr-collection-deployer-image' pipeline already exists in another repo and is being used by other pipelines successfully.

if I remove the second pipeline 'persons-api-sandbox' as dependency from 'persons-api-development' like below, then its all successful:

  persons-api-development:
    group: APIPersonSolrCollection
    materials:
      upstream:
        type: dependency
        pipeline: build-solr-collection-deployer-image
        stage: build-image
    stages: # list of stages in order
      - deploy: # name of stage
          clean_workspace: true
          jobs:
            deploy-solr-collection-to-dev-servers: # name of the job
              tasks:
               - fetch: # indicates type of task
                   pipeline: build-solr-collection-deployer-image
                   source: image_ref
                   stage: build-image
                   job: build-image
                   is_file: yes
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker run -e HOST=development -e COLLECTION=api_persons -e GIT_REPO=http://githuben.intranet.mckinsey.com/Enterprise-Architecture/persons_solr_collection.git `cat image_ref`"

Am I doing it wrong? Essentially, I didn't find an easy way to define 2 pipelines as upstream dependencies under materials. Any help would be greatly appreciated!

Whitelist does not work if pipeline has an upstream pipeline as material

Update: I had to correct my example, please see #50 (comment).

In a nutshell I have this config:

pipelines:
  p1:
    materials:
      my-repo:
        git: some-url
        auto_update: true
    stages:
      # (...)
  p2:
    materials:
      my-repo:
        git: some-url
        whitelist:
          - some-dir/**/*
        auto_update: true
      p1-as-upstream:
        pipeline: p1
        stage: some-stage

Now if I commit something outside of some-dir, I expect p2 not triggered, but it does, both pipelines are built. That sounds wrong. The whitelisting works fine if I remove p1-as-upstream from the p2 materials.

Do you know why it is not working? Is it a YAML config plugin bug or a GoCD bug?

Support configuration templates

Templates in configuration repositories

In my understanding GoCD pipeline templates were introduced at all is because any organization faces some similarity in the pipelines they declare. User can have a template with some configuration pre-defined and parameterized. So that rather than declare a full pipeline with all its stages, jobs and tasks, one may provide a few key-value pairs and tell GoCD to expand a template. This is basically a feature to support the DRY (Don't repeat yourself) priciple.
Internally this is exactly what happens, XML parameters are replaced by some variables which are in the scope of particular pipeline definition, eventually pipeline configuration instance expanded from template is not different in any way from explictly defined one. It is also not any different than a pipeline returned by configrepo extension point to server.

Once in a while a GoCD user will come along and say that he has found a pattern in all his pipelines, but it is impossible to express it with current pipeline-template model. A few examples:

  • I want pipeline name to be computed from one or more parameters.
  • I want all pipeline parameters to be computed from the sole SCM repository address.
  • I just want one stage/job/task to be exactly like some-url but to manually configure the other stages/jobs/tasks.
  • I want the parameter in my template to be a list or object, not just a key-value string.
  • I want to expand these 4 complex parameters into 8 pipelines

I propose to

  • Expand pipeline template into full pipelines outside of GoCD server - that means in configuration repository plugin.
  • Use existing, powerful templating engines to template the configuration elements. E.g. Ruby ERB, mustache, jtwig, anything user likes.
  • Use templates for anything, not just full pipeline.

Some questions come along then..

If organization has templates to be shared among many projects (many repositories) then where should the templates be stored and hosted? For private pipelines and templates, this could be a repository with limited access. But there could be public templates too, users could be sharing pieces of configuration on github, just like we share libraries. (PS: @arvindsv I guess this is was what you mentioned once before).

How to reference reference remote configuration elements/templates from particular configuration repository? E.g. if you are a SCM-fanatic then you'll want to put templates themselves in a git repository. Then easiest way is to use a gitsubmodule to have your templates checked out in the configuration repo subdirectory, e.g. gocd-templates. Then configuration repository code looks like this:

# Super early draft!!
pipelines:
  my_dry_pipeline:
    group: rich
    label_template: "${mygit[:8]}"
    tracking_tool:
      $ref: "file://gocd-templates/issue_tracker.gocd.yaml"
    ...

But another method could be a http link reference like so:

# Super early draft!!
pipelines:
  my_dry_pipeline:
    group: rich
    label_template: "${mygit[:8]}"
    tracking_tool:
      $ref: "http://gocd-templates.example.org/issue_tracker.gocd.yaml"

The first method has gocd-templates as a git submodule (or could be a plain directory actually), if that is versioned with exact commit, then any update in module reference will trigger pipeline configuration to be reloaded in GoCD.
In second method if content served by URL changes, Go will not know about it, configuration will be stale until next commit is pushed. It might be undesired in some cases.

The right templating engine

I am currently looking into which engine would fit best here. It should rather have java implementation because GoCD plugins limitations. It should be powerful but also easy to use and learn.
Recently I discovered jtwig, I really like the modularity part of it.

If you have any suggestions, please say so.

Discussion

If you have managed 100+ pipelines then you know exactly all the shortcomings of GoCD pipeline templates. If you have some ideas on templating pipelines or some interesting use cases, then please share.

Support YAML aliases in dedicated section

Hey there,

YAML supports aliases out of the box. See these use cases for example, and the spec here.

As this is supported by standard yaml parsers, it's already possible to use aliases for pipeline configs to reduce duplication. For example I can do something like this:

test-win2008:
  resources:
    - win2008
  tasks:
    &test_tasks # define the whole task list as an alias
    - exec:
        command: my_build_cmd.sh
        arguments:
          - "-DConfiguration=Release"
          - "init"
    - exec:
        command: my_build_cmd.sh
        arguments:
          - "-DConfiguration=Release"
          - "build"
    - exec:
        command: my_build_cmd.sh
        arguments:
          - "-DConfiguration=Release"
          - "test"
test-win2012:
    resources:
      - win2012
    tasks: *test_tasks # use the previously defined alias
test-win7:
    resources:
      - win7
    tasks: *test_tasks # use the previously defined alias

So we use an alias to reuse the same list of tasks in multiple jobs running on different platforms.

This works well enough, but we are forced to define the alias the first time we use it somewhere in the yaml config where it is actually valid. This makes it harder to understand where aliases come from and more error prone to reorder sections in the config. It's also not possible, to my knowledge, to only define a part of a task list as an alias. In the above example, maybe I only want the first two exec tasks to be part of the alias, not the final one.

Therefore, I suggest supporting a dedicated aliases section like the one used on the first example page.
That's currently not possible because the plugin will complain about an invalid key:

cd.go.plugin.config.yaml.YamlConfigException: aliases is invalid, expected pipelines or environments

Since the yaml parser takes care of resolving aliases, I reckon it wouldn't require many changes, besides dropping the aliases section after parsing as it's no longer needed.

Pipeline sorting or order mismatch from yaml file

Hi there, I'm starting using plugin. I have gocd 16.8.0 and plugin 0.2.0, and my pipelines are being sort in a weird way in the dashboard.

I have 3 repos with yaml configs, and one of them is sort ok: First, Second, Third, the other one is: First, Third, Second and the last one is complete backwards: Third, Second, First.

The yaml's are in the right order.

Is there a way to fix this?

Here is an example of the files, all 3 look the same:

pipelines:
  build_pipeline:
    group: groupA
    label_template: ...
    materials:
      svn_material:
        svn: ...
    stages:
      - build:
          approval: success
          fetch_materials: yes
          clean_workspace: true
          jobs:
            build:
              tasks:
                - plugin:
                    run_if: passed
                    options:
                      script: ...
                    configuration:
                      id: script-executor
                      version: 1
              artifacts:
                - build:
                    source: "*"
                    destination: all

  beta_pipeline:
    group: groupA
    label_template: "${build_pipeline}"
    locking: false
    environment_variables:
      ...
    secure_variables:
      ...
    materials:
      build_pipeline:
        pipeline: build_pipeline
        stage: build
    stages:
      - beta:
          approval: success
          fetch_materials: yes
          clean_workspace: true
          jobs:
            beta:
              tasks:
                - fetch:
                    run_if: passed
                    pipeline: build_pipeline
                    stage: build
                    job: build
                    is_file: no
                    source: all
                    destination: build_pipeline
                - plugin:
                    run_if: passed
                    options:
                      script: ...
                    configuration:
                      id: script-executor
                      version: 1
              artifacts:
                - build:
                    source: dist/*.zip
                    destination: dist

  release_pipeline:
    group: groupA
    label_template: "${build_pipeline}"
    locking: false
    environment_variables:
      ...
    secure_variables:
      ...
    materials:
      build_pipeline:
        pipeline: build_pipeline
        stage: build
      beta_pipeline:
        pipeline: beta_pipeline
        stage: beta
    stages:
      - release:
          approval: manual
          fetch_materials: yes
          clean_workspace: true
          jobs:
            release:
              tasks:
                - fetch:
                    run_if: passed
                    pipeline: build_pipeline
                    stage: build
                    job: build
                    is_file: no
                    source: all
                    destination: build_pipeline
                - fetch:
                    run_if: passed
                    pipeline: beta_pipeline
                    stage: beta
                    job: beta
                    is_file: no
                    source: dist
                    destination: beta_pipeline
                - plugin:
                    run_if: passed
                    options:
                      script: ...
                    configuration:
                      id: script-executor
                      version: 1

thanks!

how to get a dynamic value (${GO_VERSION}) evaluated in the yml for a task

I have a bash command in my gocd.yaml file, like following:

              tasks:
               - exec: # indicates type of task
                   command: bash
                   arguments:
                    - "-c"
                    - "docker build --no-cache -t 10.191.60.17:5000/mck/solr_collection_deployer:latest -t 10.191.60.17:5000/mck/solr_collection_deployer:${GO_REVISION} ."

${GO_REVISION} worked just fine when its right there in the XML config, however, when I took it out in YML template and created the pipeline using the above snippet (ignoring the code above and below it), the ${GO_REVISION} doesn't seem to get evaluated...

what am I doing wrong? any help would be much appriciated

Encrypting values

Hi,

Thanks for the great work. I'm trying out the configuration feature and I can't find correct way of encrypting the values to be put in the yml file. I couldn't find much in the docs, could you please provide some more information?

scm type not working

Hi there,

I have this in my cruise-config.xml:

  <scms>
    <scm id="3ce0ae9a-003d-4af6-b055-49a5eb5b9e79" name="boat">
      <pluginConfiguration id="git.fb" version="1" />
      <configuration>
        <property>
          <key>url</key>
          <value>http://example.com/boatymcboatface.git</value>
        </property>
        <property>
          <key>branchwhitelist</key>
          <value>*</value>
        </property>
        <property>
          <key>branchblacklist</key>
          <value>master</value>
        </property>
      </configuration>
    </scm>
  </scms>
  <config-repos>
    <config-repo plugin="yaml.config.plugin">
      <git url=http://example.com/boatymcboatface.git" />
    </config-repo>
  </config-repos>

And then I have this in my pipeline.yaml:

pipelines:
  branchTest:
    group: basic
    locking: off
    materials:
      scm: "3ce0ae9a-003d-4af6-b055-49a5eb5b9e79"
      dest: app
    stages: # list of stages in order
      - build: # name of stage
          clean_workspace: true
          jobs:
            firstJob: # name of the job
              elastic_profile_id: tests
              tasks: # ordered list of tasks to execute in job csharp
               - exec: # indicates type of task
                   command: make
                   arguments:
                    - test

The only error I am getting is:

2017-01-31 14:48:54,080 ERROR [104@MessageListener for ConfigMaterialUpdater] GoRepoConfigDataSource:158 - Failed to parse configuration material http://example.com/boatymcboatface.git by Plugin yaml.config.plugin

the thing that makes me wonder if this is actually a defect is that the code appears to transform the scm material into scm_id with type set to plugin, while the go.cd docs suggest that:

    <materials>
      <scm ref="3ce0ae9a-003d-4af6-b055-49a5eb5b9e79" dest="dest">
      </scm>
    </materials>

Is the valid output. Am I just doing it wrong, or is the code producing wrong configuration?

Cheers,

Change pipeline environment fail

I had the following environment:

environment:
  Prod:
    pipelines:
      - sample-pipeline-site0
      - sample-pipeline-site1

When I want change site1 to environment Prod-datacenter2 is expected just change the configuration to:

environment:
  Prod:
    pipelines:
      - sample-pipeline-site0
  Prod-datacenter2:
    pipelines:
      - sample-pipeline-site1

But just that not change the environment. I need before complete remove the pipeline definition.

environment:
  Prod:
    pipelines:
      - sample-pipeline-site0

"lock_behavior: unlockWhenFinished" seems not working

Here's the snippet of my pipeline:

    label_template: ${App_Build}
    lock_behavior: unlockWhenFinished
    materials: *Materials

GoCD Server Version = 16.8.0 (3929-4d871a65f9a14b157006236d8fda3460bcafcadb)
YAML Plugin Version = 0.6.0
However, the pipeline doesn't seem to lock while it is running. Is there something I missed? I tried lockOnFailure, same result. Please see snapshot below.
unlockwhenfinished_notworking

using GO_PIPELINE_LABEL

Hi,

I am trying to use $GO_PIPELINE_LABEL while packaging my application. But so far non of my attempts worked. I can use label_temoplate : ${COUNT} but when it comes to using it in -exec task like ;

- exec:
command: /bin/bash
arguments:
- -c
- echo
- $GO_PIPELINE_LABEL

or

- exec:
command: echo
arguments:
- $GO_PIPELINE_LABEL

or

- exec:
command: echo
arguments:
- $COUNT

or

- exec:
command: echo
arguments:
- ${COUNT}

Do you have any idea about how I can make this work?

Support YAML merge syntax

On the back of the handy 'common' section introduced in #32, it would be really handy if this plugin supported the YAML merge key, like this:

common:
  material_yaml_config_plugin: &material_yaml_config_plugin
    git: [email protected]:tomzo/gocd-yaml-config-plugin.git
    auto_update: false
  material_gocd:
    git: [email protected]:gocd/gocd.git
    auto_update: false
    blacklist:
      - externals/**/*.*

pipelines:
  a_pipeline:
  materials:
    yaml_config_plugin:
      <<: *material_yaml_config_plugin
      destination: yaml_config_plugin
    gocd:
      <<: *material_gocd
      destination: gocd

I had a look at yamlbeans recently and it seems it now has support for this, but a release has not been made since then. EsotericSoftware/yamlbeans@095d83d

Agents not visible in UI when added from configuration

Realistically speaking I don't know if this is an UI or configuration issue. We've integrated today GO.cd + this beautiful plugin (congrats) and we've also assigned agents to a specific environment (using their UUID). There's however an issue:

  • the agents are assigned to the environment;
  • but they don't show-up in the UI;
  • no matter how many page refreshes we do, the same thing happens;
  • to note, we're using the latest GO.cd (17+);

Acces to a private repo

I have a private bitbucket repo, the module don't pull it by httpp because don't have the permissions.
Did you know how can I solve that please?

generic java.lang.String cannot be cast to java.util.Map failure

there's some dumb issue that's preventing me from getting an MVP working. Here's the error:

Parsing configuration repository using Plugin yaml.config.plugin failed for material: URL: [email protected]/repo.git, Branch: master [Dec-01 22:50:02]
codebuild/provisioning.gocd.yml; - Failed to parse pipeline provisioning; java.lang.String cannot be cast to java.util.Map

And the yaml mentioned:

---
format_version: 1
pipelines:
  provisioning:
    group: ops
    materials:
      provisioning:
        git: '[email protected]/repo.git'
    stages:
    - build:
      jobs:
        hello:
          tasks:
          - exec:
            command: env

That's pretty minimal! It passes yamllint, and this plugin doesn't help me with which parameter is wrong, except that it's somewhere inside my pipeline.

P4 material passwd exposed

Hi,

Is there a way to hide the password of the P4 materials? I've tried using the encrypted value and it seems that's not working.

Thanks,
George

Setup on GoCD version 17.x

I'm working with GoCD version 17.x and download the .jar as the setup says but I got this error

image

Any ideas?

Moving pipelines to another environment, does not update UI

Hello,

We had pipelines in two environments, then moved some of them into a new Environment. While the code (YAML) declares the proper grouping, the new environments exist on the "Environments" page but the main page UI still groups the pipelines in the old environment, while the Environments page shows them in their proper environment.

Any idea why there's a lag on the first dashboard page or what needs to reset?

Unable to load config with dependencies between YAML-derived pipelines

I've just manually converted all of my pipelines from the monolithic cruise-config.xml to individual YAML files. Upon restarting my server, the plugin is unable to load the config:

2017-01-11 14:52:23,206  WARN [104@MessageListener for ConfigMaterialUpdater] GoFileConfigDataSource:310 - Merged config update operation failed on LATEST 2 partials. Falling back to using LAST VALID 1 partials. Exception message was: 13+ errors :: "aci-packerizer :: build-aci :: build" tries to fetch artifact from pipeline "centos-aci-builder" which does not exist.;; Pipeline "centos-aci-builder" does not exist. It is used from pipeline "aci-packerizer".;; Pipeline with name 'centos-aci-builder' does not exist, it is defined as a dependency for pipeline 'aci-packerizer' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; Pipeline "tf-vm-images" does not exist. It is used from pipeline "tf-env-ci".;; Pipeline with name 'tf-vm-images' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'tf-environment' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'aci-terraformer' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; 
com.thoughtworks.go.config.exceptions.GoConfigInvalidMergeException: 13+ errors :: "aci-packerizer :: build-aci :: build" tries to fetch artifact from pipeline "centos-aci-builder" which does not exist.;; Pipeline "centos-aci-builder" does not exist. It is used from pipeline "aci-packerizer".;; Pipeline with name 'centos-aci-builder' does not exist, it is defined as a dependency for pipeline 'aci-packerizer' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; Pipeline "tf-vm-images" does not exist. It is used from pipeline "tf-env-ci".;; Pipeline with name 'tf-vm-images' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'tf-environment' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'aci-terraformer' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; 
    at com.thoughtworks.go.config.MagicalGoConfigXmlLoader.validateCruiseConfig(MagicalGoConfigXmlLoader.java:142)
    at com.thoughtworks.go.config.MagicalGoConfigXmlLoader.preprocessAndValidate(MagicalGoConfigXmlLoader.java:117)
    at com.thoughtworks.go.config.MagicalGoConfigXmlWriter.write(MagicalGoConfigXmlWriter.java:77)
    at com.thoughtworks.go.config.GoFileConfigDataSource.configAsXml(GoFileConfigDataSource.java:472)
    at com.thoughtworks.go.config.GoFileConfigDataSource.getUnmergedConfig(GoFileConfigDataSource.java:399)
    at com.thoughtworks.go.config.GoFileConfigDataSource.trySavingConfig(GoFileConfigDataSource.java:383)
    at com.thoughtworks.go.config.GoFileConfigDataSource.writeWithLock(GoFileConfigDataSource.java:304)
    at com.thoughtworks.go.config.CachedGoConfig.writeWithLock(CachedGoConfig.java:130)
    at com.thoughtworks.go.config.GoConfigDao.updateConfig(GoConfigDao.java:116)
    at com.thoughtworks.go.server.service.GoConfigService.updateConfig(GoConfigService.java:244)
    at com.thoughtworks.go.config.GoPartialConfig.updateConfig(GoPartialConfig.java:125)
    at com.thoughtworks.go.config.GoPartialConfig.onSuccessPartialConfig(GoPartialConfig.java:85)
    at com.thoughtworks.go.config.GoRepoConfigDataSource.notifySuccessListeners(GoRepoConfigDataSource.java:184)
    at com.thoughtworks.go.config.GoRepoConfigDataSource.onCheckoutComplete(GoRepoConfigDataSource.java:153)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.updateConfigurationFromCheckout(ConfigMaterialUpdater.java:115)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.onMessage(ConfigMaterialUpdater.java:95)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.onMessage(ConfigMaterialUpdater.java:39)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:69)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:50)
    at java.lang.Thread.run(Thread.java:745)
2017-01-11 14:52:23,235  WARN [104@MessageListener for ConfigMaterialUpdater] GoFileConfigDataSource:318 - Merged config update operation failed using fallback LAST VALID 2 partials. Exception message was: 13+ errors :: "aci-packerizer :: build-aci :: build" tries to fetch artifact from pipeline "centos-aci-builder" which does not exist.;; Pipeline "centos-aci-builder" does not exist. It is used from pipeline "aci-packerizer".;; Pipeline with name 'centos-aci-builder' does not exist, it is defined as a dependency for pipeline 'aci-packerizer' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; Pipeline "tf-vm-images" does not exist. It is used from pipeline "tf-env-ci".;; Pipeline with name 'tf-vm-images' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'tf-environment' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'aci-terraformer' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; 
com.thoughtworks.go.config.exceptions.GoConfigInvalidMergeException: 13+ errors :: "aci-packerizer :: build-aci :: build" tries to fetch artifact from pipeline "centos-aci-builder" which does not exist.;; Pipeline "centos-aci-builder" does not exist. It is used from pipeline "aci-packerizer".;; Pipeline with name 'centos-aci-builder' does not exist, it is defined as a dependency for pipeline 'aci-packerizer' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; Pipeline "tf-vm-images" does not exist. It is used from pipeline "tf-env-ci".;; Pipeline with name 'tf-vm-images' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'tf-environment' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'aci-terraformer' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; 
    at com.thoughtworks.go.config.MagicalGoConfigXmlLoader.validateCruiseConfig(MagicalGoConfigXmlLoader.java:142)
    at com.thoughtworks.go.config.MagicalGoConfigXmlLoader.preprocessAndValidate(MagicalGoConfigXmlLoader.java:117)
    at com.thoughtworks.go.config.MagicalGoConfigXmlWriter.write(MagicalGoConfigXmlWriter.java:77)
    at com.thoughtworks.go.config.GoFileConfigDataSource.configAsXml(GoFileConfigDataSource.java:472)
    at com.thoughtworks.go.config.GoFileConfigDataSource.getUnmergedConfig(GoFileConfigDataSource.java:399)
    at com.thoughtworks.go.config.GoFileConfigDataSource.trySavingConfig(GoFileConfigDataSource.java:383)
    at com.thoughtworks.go.config.GoFileConfigDataSource.writeWithLock(GoFileConfigDataSource.java:314)
    at com.thoughtworks.go.config.CachedGoConfig.writeWithLock(CachedGoConfig.java:130)
    at com.thoughtworks.go.config.GoConfigDao.updateConfig(GoConfigDao.java:116)
    at com.thoughtworks.go.server.service.GoConfigService.updateConfig(GoConfigService.java:244)
    at com.thoughtworks.go.config.GoPartialConfig.updateConfig(GoPartialConfig.java:125)
    at com.thoughtworks.go.config.GoPartialConfig.onSuccessPartialConfig(GoPartialConfig.java:85)
    at com.thoughtworks.go.config.GoRepoConfigDataSource.notifySuccessListeners(GoRepoConfigDataSource.java:184)
    at com.thoughtworks.go.config.GoRepoConfigDataSource.onCheckoutComplete(GoRepoConfigDataSource.java:153)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.updateConfigurationFromCheckout(ConfigMaterialUpdater.java:115)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.onMessage(ConfigMaterialUpdater.java:95)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.onMessage(ConfigMaterialUpdater.java:39)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:69)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:50)
    at java.lang.Thread.run(Thread.java:745)
2017-01-11 14:52:23,238  WARN [104@MessageListener for ConfigMaterialUpdater] GoFileConfigDataSource:331 - Configuration file is invalid: 13+ errors :: "aci-packerizer :: build-aci :: build" tries to fetch artifact from pipeline "centos-aci-builder" which does not exist.;; Pipeline "centos-aci-builder" does not exist. It is used from pipeline "aci-packerizer".;; Pipeline with name 'centos-aci-builder' does not exist, it is defined as a dependency for pipeline 'aci-packerizer' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; Pipeline "tf-vm-images" does not exist. It is used from pipeline "tf-env-ci".;; Pipeline with name 'tf-vm-images' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'tf-environment' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'aci-terraformer' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; 
com.thoughtworks.go.config.exceptions.GoConfigInvalidMergeException: 13+ errors :: "aci-packerizer :: build-aci :: build" tries to fetch artifact from pipeline "centos-aci-builder" which does not exist.;; Pipeline "centos-aci-builder" does not exist. It is used from pipeline "aci-packerizer".;; Pipeline with name 'centos-aci-builder' does not exist, it is defined as a dependency for pipeline 'aci-packerizer' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; Pipeline "tf-vm-images" does not exist. It is used from pipeline "tf-env-ci".;; Pipeline with name 'tf-vm-images' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'tf-environment' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'aci-terraformer' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; 
    at com.thoughtworks.go.config.GoFileConfigDataSource.writeWithLock(GoFileConfigDataSource.java:321)
    at com.thoughtworks.go.config.CachedGoConfig.writeWithLock(CachedGoConfig.java:130)
    at com.thoughtworks.go.config.GoConfigDao.updateConfig(GoConfigDao.java:116)
    at com.thoughtworks.go.server.service.GoConfigService.updateConfig(GoConfigService.java:244)
    at com.thoughtworks.go.config.GoPartialConfig.updateConfig(GoPartialConfig.java:125)
    at com.thoughtworks.go.config.GoPartialConfig.onSuccessPartialConfig(GoPartialConfig.java:85)
    at com.thoughtworks.go.config.GoRepoConfigDataSource.notifySuccessListeners(GoRepoConfigDataSource.java:184)
    at com.thoughtworks.go.config.GoRepoConfigDataSource.onCheckoutComplete(GoRepoConfigDataSource.java:153)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.updateConfigurationFromCheckout(ConfigMaterialUpdater.java:115)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.onMessage(ConfigMaterialUpdater.java:95)
    at com.thoughtworks.go.server.materials.ConfigMaterialUpdater.onMessage(ConfigMaterialUpdater.java:39)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:69)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:50)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.thoughtworks.go.config.exceptions.GoConfigInvalidMergeException: 13+ errors :: "aci-packerizer :: build-aci :: build" tries to fetch artifact from pipeline "centos-aci-builder" which does not exist.;; Pipeline "centos-aci-builder" does not exist. It is used from pipeline "aci-packerizer".;; Pipeline with name 'centos-aci-builder' does not exist, it is defined as a dependency for pipeline 'aci-packerizer' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: plan :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-environment" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "tf-vm-images" which does not exist.;; "tf-env-ci :: apply :: plan" tries to fetch artifact from pipeline "aci-terraformer" which does not exist.;; Pipeline "tf-vm-images" does not exist. It is used from pipeline "tf-env-ci".;; Pipeline with name 'tf-vm-images' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'tf-environment' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; Pipeline with name 'aci-terraformer' does not exist, it is defined as a dependency for pipeline 'tf-env-ci' ([email protected]:myorg/gocd-pipelines-platform.git at cd0e50f0ababfc9e3a7b4b7fe3864896f8069b76);; 
    at com.thoughtworks.go.config.MagicalGoConfigXmlLoader.validateCruiseConfig(MagicalGoConfigXmlLoader.java:142)
    at com.thoughtworks.go.config.MagicalGoConfigXmlLoader.preprocessAndValidate(MagicalGoConfigXmlLoader.java:117)
    at com.thoughtworks.go.config.MagicalGoConfigXmlWriter.write(MagicalGoConfigXmlWriter.java:77)
    at com.thoughtworks.go.config.GoFileConfigDataSource.configAsXml(GoFileConfigDataSource.java:472)
    at com.thoughtworks.go.config.GoFileConfigDataSource.getUnmergedConfig(GoFileConfigDataSource.java:399)
    at com.thoughtworks.go.config.GoFileConfigDataSource.trySavingConfig(GoFileConfigDataSource.java:383)
    at com.thoughtworks.go.config.GoFileConfigDataSource.writeWithLock(GoFileConfigDataSource.java:314)
    ... 13 more
2017-01-11 14:52:23,239  INFO [104@MessageListener for ConfigMaterialUpdater] GoConfigDao:121 - Config update request by anonymous is completed

It seems that dependencies between pipelines that are all defined in YAML cannot be loaded.

Apply yaml pipeline immediately using api

Hi,

I've been trying to poke gocd api to apply the yaml pipeline immediately after I pushed to config-repo, but always getting the error below. Polling works, it's just that I can't keep waiting for the polling to update the pipeline.

curl -u 'tpidor:*******' 'http://***********:8153/go/api/material/notify/git' -H 'Confirm: true' -X POST -d "repository_url=git@********/tpidor/gocd_pipeline_****.git" 

log -

Unable to find material. Materials must be configured not to poll for new changes before they can be used with the notification mechanism.

This is in config xml -

    <config-repo plugin="yaml.config.plugin">
      <git url="git@**********:tpidor/gocd_pipeline_****.git" branch="test_branch_poc" />
    </config-repo>

Tried curl as well as mentioned in #20 but no luck.

http://**************:8153/go/api/material/notify/git/?repository_url=git@*************:tpidor/gocd_pipeline_****.git

Result: The url [ /go/api/material/notify/git ] you are trying to reach doesn't appear to be correct.

By the way, GoCD version = 16.8.
Anything I missed here? Appreciate any help. Thanks.

Use GoCD environment variables in task config

Is it possible to use a environment variable such as GO_PIPELINE_NAME in the task configuration?

I tried snippet below and that fails to resolve the name.

              tasks:
                - fetch:
                    pipeline: "${GO_PIPELINE_NAME}"
                    stage: build

Basically, I'd like to not hard code the name of the pipeline (self) when fetching the build artifact so that I can alias the whole block and re-use it in other pipelines.

runtime error when using yaml anchor <<:

image
runtime; - Unexpected error when handling plugin response java.lang.NullPointerException

image

deploy-dev: &deploy_pipeline
group: aws
materials: &deploy_pipeline_materials
git-a: *baybridge
git-bb: *baybridge-apps
create-ami:
pipeline: initialize
stage: xxx
deploy-qa:
group: aws
materials:
<<: *deploy_pipeline_materials
deploy-dev:
pipeline: deploy-dev
stage: xxx

Error messages about parsing does not contain any clues in the log

Here is a sample from the log:
GoRepoConfigDataSource:158 - Failed to parse configuration material https://github.com/cblomqvist/gocd-pipelines-yaml.git by Plugin yaml.config.plugin

Here is the error message I can see in the GoCD GUI when clicking the Error notification in the bottom right corner:
ci.gocd.yaml; - Failed to parse pipeline pac1_privatpension; java.util.ArrayList cannot be cast to java.util.Map

It is slightly better but more clues of where that error happens would be nice.

Is it possible to define template in yaml format?

Hi, maybe i overlooked it in the documentation, but how can i specify the pipeline as template , so i can set the reference as in one of the examples.
and related question: how can i specify reference to the parameter in the pipeline,
eg.
mypipe1: # definition of mypipe1 pipeline
...
parameters: # list of parameters that can be configured for a pipeline
param1: value1
jobs:
test:
environment_variables:
param1: #{param1}

it does not work. :(.
thank you

How to add pipeline to environment

How can I add pipeline (thats defined in yaml file) into environment thats defined in GoCD server xml or another yaml file. When I add environment: block to the file it will complain that this environment already excists.

No error when 2 materials with the same names

My pipeline depends on 2 upstream pipelines (P1 and P2) and 1 git repository. My config contains:

materials:
      git:
        git: "git@<path_to_git_project>.git"
        branch: ci
      upstream:
        pipeline: P1
        stage: test
      upstream:
        pipeline: P2
        stage: itest

It would be nice if there was an error saying that I configured 2 materials with the same name: upstream. Currently such configuration results in ignoring 1 upstream pipeline material.

Pipelines dont appear

Hi,

I was able to successfully load two pipelines using YAML config. I tried with a couple of more repositories and no matter what I do I cant see the pipelines appear. I even restarted the GoServer. I am using GoCD version 17.10.0 and 0.4.0 version of the YAML Plugin.

I dont see any errors in the log and I dont see any errors reported by the GoCD Web Interface. Any suggestions on how to resolve this would be great.

Here are the logs I see when I add a new config-repo:

INFO [qtp2008362258-32] GoConfigDao:147 - Config update request by <userid> is completed
INFO [qtp2008362258-29] MagicalGoConfigXmlWriter:85 - [Serializing Config] Generating config partial.
INFO [91@MessageListener for ConfigMaterialUpdater] GoConfigDao:111 - Config update request by anonymous is in queue - com.thoughtworks.go.config.GoPartialConfig$GoPartialUpdateCommand@6ffcb9dc
INFO [91@MessageListener for ConfigMaterialUpdater] GoConfigDao:114 - Config update request com.thoughtworks.go.config.GoPartialConfig$GoPartialUpdateCommand@6ffcb9dc by anonymous is being processed
INFO [91@MessageListener for ConfigMaterialUpdater] MagicalGoConfigXmlWriter:85 - [Serializing Config] Generating config partial.
INFO [91@MessageListener for ConfigMaterialUpdater] GoFileConfigDataSource:483 - [Configuration Changed] Saving updated configuration.
INFO [91@MessageListener for ConfigMaterialUpdater] CachedGoConfig:226 - About to notify config listeners
INFO [91@MessageListener for ConfigMaterialUpdater] BuildAssignmentService:253 - [Configuration Changed] Removing jobs for pipelines that no longer exist in configuration.
INFO [91@MessageListener for ConfigMaterialUpdater] CachedGoConfig:234 - Finished notifying all listeners
INFO [91@MessageListener for ConfigMaterialUpdater] GoConfigDao:129 - Config update request by anonymous is completed

The pipeline.gocd.yaml file looks like this:

pipelines:
  AppDevelopment:
    group: "Development"
    label_template: "1.0.${COUNT}"
    locking: "off"
    materials:
      c:
        git: "[email protected]:company/c.git"
        branch: "master"
    stages:
      - Tests:
          resources:
           - "python3"
          jobs:
            UnitTests:
              tasks:
               - exec:
                  command: "sh"
                  arguments:
                    - "-c"
                    - "echo build"
      - Publish:
          resources:
           - "docker"
          jobs:
            PublishArtifact:
              tasks:
               - exec:
                   command: "sh"
                   arguments:
                     - "-c"
                     - "echo publish"

This is how the relevant parts of config.xml looks like:

   ...
   ...
 </security>
  </server>
  <config-repos>
    <config-repo pluginId="yaml.config.plugin" id="a-repo">
      <git url="[email protected]:company/a.git" />
    </config-repo>
    <config-repo pluginId="yaml.config.plugin" id="b-repo">
      <git url="[email protected]:company/b.git" />
    </config-repo>
    <config-repo pluginId="yaml.config.plugin" id="c-repo">
      <git url="[email protected]:company/c.git" />
    </config-repo>
    <config-repo pluginId="yaml.config.plugin" id="d-repo">
      <git url="[email protected]:company/d.git" />
    </config-repo>
  </config-repos>
  <pipelines group="Development" />
  <pipelines group="Verification" />
  <pipelines group="Production" />

incorrect behaviour after change secure_variable value in template

Hi,
First of all, this is just minor issue, but maybe could be interesting for other, who may face same issue.
Go Version: 17.11.0 (5520-9f6909e2f64b07d2dce5cecd4ea5b92b8e19d6b1).
Yaml Plugin: 0.6.0

There are some similar pipelines (written using yaml), which are referred to template (they just have different parameters). After the request to change password for one of tech account, the password has been changed in template via UI , but pipelines started to failed with 401. After, manual test, it looks like the old value somehow has been cached and reused, instead of actual one.
Agent && server restart didnot help, but deleting the pipeline folder on the agent did the thing and connection to backend from those pipeline became successful again.

Error parsing pipeline JSON with SonarQube Quality Gates Task

This is the error given when parsing Pipeline config with tasks type 'pluggable_task' (From SonarQube Quality Gates Task Plugin)

Parsing configuration repository using Plugin json.config.plugin failed for material: URL: https://bitbucket.org/....etc...etc....., Branch: master [Sep-05 08:00:27]
runtime; - Unexpected error when handling plugin response com.google.gson.JsonParseException: Invalid or unknown task type 'pluggable_task'

Portion of pipeline json with this task type:

            {
              "type": "pluggable_task",
              "attributes": {
                "run_if": [
                  "passed"
                ],
                "on_cancel": null,
                "plugin_configuration": {
                  "id": "sonar.quality.gate.plugin",
                  "version": "1"
                },
                "configuration": [
                  {
                    "key": "SonarProjectKey",
                    "value": "test:project:new_test1"
                  },
                  {
                    "key": "IssueTypeFail",
                    "value": "error"
                  },
                  {
                    "key": "SonarApiUrl",
                    "value": "http://our_sonar_url/api"
                  }
                ]
              }
            },

This plugin is very useful but we cant use it by this error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.