Skip to content

chef-partners/azuredevops-chef

Repository files navigation

Chef Integration for Azure Pipelines

Build Status

This repo contains tasks for Azure Pipelines to effect changes using the Chef API.

The following tasks are available:

  • Cookbook Version: Set the cookbook version number
  • Update Environment: Sets a cookbook version constraint on the specified environment
  • Environment Variables: Set the variables on a Release environment as attributes on the Chef environment
  • Execute Chef Client: Execute Chef-Client
  • Execute Inspec: Execute Inspec
  • Execute Knife: Exeucte Knife command in the context of the specified Chef Server endpoint
  • Gem Install: InstallGem into the ChefDK context
  • Install ChefDK: Install ChefDK onto the Azure Pipelines Agent. (See restrictions below)
  • Install Inspec: Install Inspec on a Deployment Group machine
  • Publish to Supermarket: Publish the cookbook to a supermarket
  • Upload Cookbook: Upload the cookbook (and dependencies) to a Chef Server
  • Test Kitchen: Perform testing using Test Kitchen in Azure

Building

The aim of ths repo is to have multiple tasks from one extension. However a task is not able to depend on any code or libraries that are not at the same level as the task code. This means that at build time the relevant files and directories need to be copied. When performing a build there are build tasks that assist with this.

All output from a build will be placed into the build directory.

npm run build:tasks
npm run package:tasks

Development

Run the following to configure the local environment:

npm run init:dev

When developing it is recommended that Visual Studio Code is used. There are tasks for VS Code that have been setup to allow for debugging and compliation of TypeScript files.

The following must be configured before attempting to debug:

  • A symlink to the common folder must be present in each task. This is so that a copy of the dependent libraries is built into the dist folder at compile time.
  • The node_modules from the specific task directory needs to be copied to the relevant output dir in dist. This is so that the JavaScript can find the necessary files.

The VSCode configuration will ensure that all compliations of TypeScript files will be copied into dist directory.

Each task has its own package.json file that has the dependencies for the task which is why it has to be copied to the output directory,

When a new task is created then the build tasks in the root package.json will need be updated, namely the initdev:npm and build:tasks:noclean tasks.

NPM Tasks

The following table shows a list of all the NPM tasks that have been created.

Name Description
initdev:npm Install packages for tasks. This needs to be ammended for each new task
initdev:typngs Install the typings for tasks (not individual)
initdev Wrapper for above two tasks
clean Remove the build directory
compile:scripts Compile the scripts that are required during the build. Compile the tasks as defined by the tasks/tsconfig.build.json
lint Lint TypeScript files in the scripts and tasks folders, but not in nested node_modules
build:tasks:noclean Execute the scripts/build.js run command to perform all build and package tasks

Build Process

The entire build process is governed by the build.js script (so it needs to be compiled using compile:scripts). The options for the build script are as follows:

  Usage: build [options] [command]

  VSTS Extension Builder


  Options:

    -V, --version               output the version number
    -b, --buildconfig [file]    Specify the build configuration file to use
    -t, --tasksdir [directory]  Path to the tasks folder
    --tfxpath [path]            Path to the TFX executable
    --tscpath [path]            Path to the TSC executable
    --tslintpath [path]         Path to the TSLint executable
    -h, --help                  output usage information


  Commands:

    lint [options]           Lint the Typescript files
    copylibs                 Copy libraries to extension tasks
    taskdeps                 Iterate around the tasks and install dependencies
    compiletasks [options]   Compile the typescript tasks into JavaScript
    copyfiles                Copy static files into the built extension
    version [options]        Version extension and tasks
    preview                  Create the preview extension
    manifest                 Set the flags on the extensions
    package                  Build the package files for each extension
    run [options]            Run the entire build process

This help text can be seen by running node scripts/build.js --help.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published