Skip to content

Allow reordering config repo pipelines#6043

Merged
marques-work merged 4 commits intogocd:masterfrom
arvindsv:allow-reordering-config-repo-pipelines
Apr 2, 2019
Merged

Allow reordering config repo pipelines#6043
marques-work merged 4 commits intogocd:masterfrom
arvindsv:allow-reordering-config-repo-pipelines

Conversation

@arvindsv
Copy link
Member

@arvindsv arvindsv commented Mar 30, 2019

Attempt to implement #6042.

See documentation for:

How it works:

At the level of a pipeline (for instance, here), add a property called: display_order set to any integer. When the repository is parsed and the pipeline is shown in the dashboard, the order of the pipelines in each group is based on their weight, lowest to highest. Pipelines defined in XML have a weight of -1 and there is no way provided to change that.

Ideally, the format_version of the JSON file should be changed to 4, but earlier versions will also work.

Example:

{
  "format_version" : 4,
  "display_order": 11,

  "name": "allmaterials",
  "group" : "configrepo-example",
  "enable_pipeline_locking": true,
  "environment_variables": [],

  "materials": [
    {
      "url": "https://github.com/tomzo/gocd-json-config-example.git",
      "type": "git",
      "name" : "mygit",
      "destination" : "mydest"
    }
...

Todo:

Note: This PR can be merged now. This doesn't need to wait for the todos. But, if no one has concerns and this gets merged, the rest can be worked on.

Scenarios considered:

  1. Target version set to 4 and display_order set to 10.
  2. Target version set to 3 and display_order set to 10. Doesn't complain. Uses 10.
  3. Target version set to 4 and display_order set to -10 (shows up before pipelines defined in XML).
  4. Target version set to 4 and no display_order is set. Defaults to -1.
  5. Different pipelines having the same weight. This works fine. The order (within those pipelines with the same weight) is indeterminate. These values are weights and not the order itself.
  6. Export to JSON/YAML might not export display_order. I'm not too worried about it. I think it's ok not to. [Checked: Works in all three plugins.]

Trying it out manually:

After building using the code from this PR, adding this repository as a JSON code repo, should work: https://github.com/arvindsv/gocd_6043

Since the JSON plugin doesn't really do much validation, it will work, even without any support added to it.

Reviewing this change:

It's not very complicated.

  1. A temporary weight is stored at the pipeline config level.

  2. A jolt migration which is tested here takes care of defaulting the value to -1. It's just to maintain consistency. This wasn't strictly needed.

  3. This is where order used to get lost, earlier.

  4. This test shows how it is used in the dashboard representer, just before sending it.

Most of the rest of the code is test files, most of which consist of just some small refactoring.

@arvindsv arvindsv added this to the Release 19.3.0 milestone Mar 30, 2019
@arvindsv arvindsv force-pushed the allow-reordering-config-repo-pipelines branch 2 times, most recently from 457d0dd to 05a00f4 Compare March 30, 2019 03:15
@arvindsv arvindsv force-pushed the allow-reordering-config-repo-pipelines branch from 05a00f4 to 29c95aa Compare March 30, 2019 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants