Skip to content

Instantly share code, notes, and snippets.

@afiune
Last active May 13, 2016 17:10
Show Gist options
  • Select an option

  • Save afiune/0d7977aa512af491c2f6a5cd4dbf2dc1 to your computer and use it in GitHub Desktop.

Select an option

Save afiune/0d7977aa512af491c2f6a5cd4dbf2dc1 to your computer and use it in GitHub Desktop.
SPOOL-140 Mini project for delivery-cli init command

Delivery-cli

Find below the list of features released in the new version of the delivery-cli (0.0.15)

Feature: Verify the CLI token

Starting from version0.0.15 the delivery-cli will verify the token expiration for every single API request to the Delivery Server. That means that if your token has expired, you will be prompted to renew it.

If you would like to know if your token has expired you can use the option --verify:

➜  delivery delivery token --verify
Chef Delivery
Loading configuration from /Users/salimafiune/chef/delivery
token: GmTtD0t7W9ySpS5pKZyw//r/6etpXYfw8uVdQccjdeU=
Verifying Token: valid

Feature: Initialize projects with a Github repository for Code Review

Required Options:

  • --github <org-name> - Use a Github repository for Code Review with the provided Organization.
  • -r, --repo-name <repo-name> - Source code provider repository name.

Example: Initialize a project called delivery-cli-init-test that lives in the chef-cookbooks git-organization.

➜  delivery-cli-init-test git:(master) delivery init --github chef-cookbooks -r delivery-cli-init-test
Chef Delivery
Loading configuration from /Users/salimafiune/chef/delivery/organizations/sandbox/delivery-cli-init-test
Is /Users/salimafiune/chef/delivery/organizations/sandbox/delivery-cli-init-test a git repo?  yes
Project delivery-cli-init-test already exists.
Creating and checking out add-delivery-config feature branch: done
Generating build cookbook skeleton
Using cached copy of build-cookbook generator "/Users/salimafiune/.delivery/cache/generator-cookbooks/pcb"
Build-cookbook generated: "chef" "generate" "cookbook" ".delivery/build-cookbook" "-g" "/Users/salimafiune/.delivery/cache/generator-cookbooks/pcb"
Adding and commiting build-cookbook: done
Writing configuration to /Users/salimafiune/chef/delivery/organizations/sandbox/delivery-cli-init-test/.delivery/config.json
New delivery configuration
--------------------------
{
  "version": "2",
  "build_cookbook": {
    "path": ".delivery/build-cookbook",
    "name": "build-cookbook"
  },
  "skip_phases": [],
  "build_nodes": {},
  "dependencies": []
}
Git add and commit delivery config: done
Push add-delivery-config branch and create Pull Request

Currently delivery-cli doesn't submit a review so you have to push the branch add-delivery-config to Github.com/GHE and create a Pull Request.

Feature: Initialize projects with a Bitbucket repository for Code Review

Required Options:

  • --bitbucket <project-key> - Use a Bitbucket repository for Code Review with the provided Project Key
  • -r, --repo-name <repo-name> - Source code provider repository name.

Example: Initialize a project called test-delivery-project that lives in the TEST Project Key.

➜  test-delivery-project git:(master) delivery init --bitbucket TEST -r test-delivery-project
Chef Delivery
Loading configuration from /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project
Is /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project a git repo?  yes
Creating bitbucket project: test-delivery-project  created
adding remote delivery: ssh://afiune@Chef@delivery.chef.co:8989/Chef/sandbox/test-delivery-project
Remote 'delivery' added to git config!
Checking for content on the git remote delivery: No upstream content
Pushing local content to server:
To ssh://afiune@Chef@delivery.chef.co:8989/Chef/sandbox/test-delivery-project
*	refs/heads/master:refs/heads/master	[new branch]
Branch master set up to track remote branch master from delivery.
Done

Creating and checking out add-delivery-config feature branch: done
Generating build cookbook skeleton
Using cached copy of build-cookbook generator "/Users/salimafiune/.delivery/cache/generator-cookbooks/pcb"
Build-cookbook generated: "chef" "generate" "cookbook" ".delivery/build-cookbook" "-g" "/Users/salimafiune/.delivery/cache/generator-cookbooks/pcb"
Adding and commiting build-cookbook: done
Writing configuration to /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project/.delivery/config.json
New delivery configuration
--------------------------
{
  "version": "2",
  "build_cookbook": {
    "name": "build-cookbook",
    "path": ".delivery/build-cookbook"
  },
  "skip_phases": [],
  "build_nodes": {},
  "dependencies": []
}
Git add and commit delivery config: done
Chef Delivery
Loading configuration from /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project
Review for change add-delivery-config targeted for pipeline master
Created new patchset
https://delivery.chef.co/e/Chef/#/organizations/sandbox/projects/test-delivery-project/changes/695f2bb9-ab21-4adf-a6e0-b9fc79854478
➜  test-delivery-project git:(add-delivery-config)

Feature: Initialize a project with a custom config.json, build-cookbook generator, and/or pipeline

These three new options are optional and you can use them to customize the way you initialize projects in Delivery. Now the option to customize your pipeline is working, you can pass a custom config.json and also provide a custom build-cookbook generator.

Options:

  • -f, --for <pipeline> - Target pipeline for change (default: master)
  • -c, --config-json <config-json> - Path of a custom config.json file.
  • --generator <generator> - Local path or Git repo URL to a custom ChefDK build-cookbook generator (default:github)

Example: You have a custom config.json file and build-cookbook generator for the projects that your developers needs to use when initializing projects in Delivery. Also your organization doesn't commit to master but instead to trunk.

➜  test-delivery-project git:(master) delivery init --generator https://github.com/afiune/bc-generator.git -c /Users/salimafiune/chef/delivery/.delivery/config.json -f trunk
Chef Delivery
Loading configuration from /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project
Is /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project a git repo?  yes
Creating delivery project: test-delivery-project  created
adding remote delivery: ssh://afiune@Chef@delivery.chef.co:8989/Chef/sandbox/test-delivery-project
Remote 'delivery' added to git config!
Checking for content on the git remote delivery: No upstream content
Pushing local content to server:
To ssh://afiune@Chef@delivery.chef.co:8989/Chef/sandbox/test-delivery-project
*	refs/heads/master:refs/heads/master	[new branch]
Branch master set up to track remote branch master from delivery.
Done

Creating trunk  pipeline for project: test-delivery-project:  created
Creating and checking out add-delivery-config feature branch: done
Generating build cookbook skeleton
Downloading build-cookbook generator from "https://github.com/afiune/bc-generator.git"
Build-cookbook generated: "chef" "generate" "cookbook" ".delivery/build-cookbook" "-g" "/Users/salimafiune/.delivery/cache/generator-cookbooks/bc-generator"
Adding and commiting build-cookbook: done
Copying configuration to /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project/.delivery/config.json
New delivery configuration
--------------------------
{
  "version": "2",
  "build_cookbook": {
    "path": ".delivery/build-cookbook",
    "name": "build-cookbook"
  },
  "skip_phases": [
    "smoke",
    "security",
    "syntax",
    "lint",
    "quality"
  ],
  "build_nodes": {},
  "delivery-truck": {
    "publish": {
      "chef_server": true
    }
  },
  "dependencies": []
}

Git add and commit delivery config: done
Chef Delivery
Loading configuration from /Users/salimafiune/chef/delivery/organizations/sandbox/test-delivery-project
Review for change add-delivery-config targeted for pipeline trunk
Created new patchset
https://delivery.chef.co/e/Chef/#/organizations/sandbox/projects/test-delivery-project/changes/9e5b6c36-8deb-4c5c-822c-52e2863b8bb6
➜  test-delivery-project git:(add-delivery-config)

If you would like to make these options persistent for every project you initilize you can add them to your cli.toml file like this:

pipeline = "trunk"
generator = "https://github.com/afiune/bc-generator.git"
config_json = "/Users/salimafiune/chef/delivery/.delivery/config.json"
@wrightp

wrightp commented May 13, 2016

Copy link
Copy Markdown

sp. verion 0.0.15 => version 0.0.15

blank sections
Feature: Initialize a project in Delivery with a custom config.json
Feature: Initialize a project in Delivery with a custom build-cookbook generator

re-write sentence: Now the option to customize your pipeline is working, you can pass a custom config.json and also provide a custom build-cookbook generator.

@rmoshier

Copy link
Copy Markdown

👍 once Patrick's comments are addressed

@afiune

afiune commented May 13, 2016

Copy link
Copy Markdown
Author

Comments have been fixed! 👍 Thank you @Patrick-Wright

@scottopherson

Copy link
Copy Markdown

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment