diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7928fa5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: generic + +sudo: false + +env: + global: + - PATH="/opt/chefdk/bin:/opt/chef/bin:/opt/chef/embedded/bin:/opt/chefdk/embedded/bin:$PATH" + +addons: + apt: + sources: + - chef-stable-precise + packages: + - chefdk + +script: chef exec rake travis diff --git a/README.md b/README.md index 020d4ed..ac3a2f0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Visual Studio Team Services Build Agent Cookbook ================ -Installs and configures Visual Studio Team Services [Build Agents](https://www.visualstudio.com/en-us/get-started/build/build-your-app-vs) (a.k.a VSO Build Agents) +Installs and configures Visual Studio Team Services [Build Agent](https://www.visualstudio.com/en-us/get-started/build/build-your-app-vs) (a.k.a VSO Build Agent) Requirements ------------ @@ -34,25 +34,25 @@ Resource/Provider ### windows This resource installs and configures a build agent on windows host #### Actions -- :install: Install and configure a build agent -- :remove: Remove a build agent and unregister it from VSTS -- :restart: Restart a build agent service +- `:install`: Install and configure a build agent +- `:remove`: Remove a build agent and unregister it from VSTS +- `:restart`: Restart a build agent service #### Parameters -- agent_name: Name attribute. The name of a build agent -- install_dir: A target directory to install a build agent -- sv_name: Set a windows service name. Default vsoagent.host.agent_name -- sv_user: Set a user name to run windows service. Possible values are "NT AUTHORITY\\NetworkService", "NT AUTHORITY\\LocalService" or any system valid username -- sv_password: Set password with sv_user unless it is equal to NetworkService or LocalService -- vsts_url: A target VSTS url -- vsts_user: A user to connect with VSTS -- vsts_token: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) -- vsts_pool: A pool name on VSTS -- work_folder: Set different workspace location. Default is "install_dir/\_work" +- `agent_name`: Name attribute. The name of a build agent +- `install_dir`: A target directory to install a build agent +- `sv_name`: Set a windows service name. Default vsoagent.host.agent_name +- `sv_user`: Set a user name to run windows service. Possible values are "NT AUTHORITY\\NetworkService", "NT AUTHORITY\\LocalService" or any system valid username +- `sv_password`: Set password with sv_user unless it is equal to NetworkService or LocalService +- `vsts_url`: A target VSTS url +- `vsts_user`: A user to connect with VSTS +- `vsts_token`: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) +- `vsts_pool`: A pool name on VSTS +- `work_folder`: Set different workspace location. Default is "install_dir/\_work" #### Examples Install, configure, restart and remove a build agent. -Check [tests](test/cookbooks/basic/recipes/xplat.rb) for more examples. +Check [tests](test/cookbooks/windows-basic/recipes/default.rb) for more examples. ```ruby include_recipe 'vsts_build_agent::default' @@ -81,26 +81,26 @@ end ### xplat This resource installs and configures a build agent on linux or macosx host #### Actions -- :install: Install and configure a build agent -- :remove: Remove a build agent and unregister it from VSTS -- :restart: Restart a build agent service +- `:install`: Install and configure a build agent +- `:remove`: Remove a build agent and unregister it from VSTS +- `:restart`: Restart a build agent service #### Parameters -- agent_name: Name attribute. The name of build agent -- install_dir: A target directory to install build agent -- user: Set a user to run build agent. -- group: Set a group to run build agent. -- sv_name: Set a service name. Default vsoagent.host.agent_name -- sv_envs: Set hash of environment variables to pass into an agent process -- sv_session: For MacOsX only. Set a LaunchAgent session. -- vsts_url: A target VSTS url -- vsts_user: A user to connect with VSTS -- vsts_token: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) -- vsts_pool: A pool name on VSTS +- `agent_name`: Name attribute. The name of build agent +- `install_dir`: A target directory to install build agent +- `user`: Set a user to run build agent. +- `group`: Set a group to run build agent. +- `sv_name`: Set a service name. Default vsoagent.host.agent_name +- `sv_envs`: Set hash of environment variables to pass into an agent process +- `sv_session`: For MacOsX only. Set a LaunchAgent session. +- `vsts_url`: A target VSTS url +- `vsts_user`: A user to connect with VSTS +- `vsts_token`: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) +- `vsts_pool`: A pool name on VSTS #### Examples Install, configure, restart and remove build agent. -Check [tests](test/cookbooks/basic/recipes/windows.rb) for more examples. +Check [tests](test/cookbooks/xplat-basic/recipes/default.rb) for more examples. ```ruby include_recipe 'vsts_build_agent::default' diff --git a/Rakefile b/Rakefile index 64c1133..c9a1fe0 100644 --- a/Rakefile +++ b/Rakefile @@ -26,3 +26,5 @@ namespace :kitchen do end task :default => ['style', 'kitchen:linux'] + +task :travis => ['style'] diff --git a/TESTING.md b/TESTING.md index a74c128..d99433a 100644 --- a/TESTING.md +++ b/TESTING.md @@ -17,7 +17,26 @@ rake style ## Integration Testing Integration tests are orchestrated by [test-kitchen](https://github.com/test-kitchen/test-kitchen). Currently kitchen.yml contains mix of public(linux) and private boxes(Windows and MacOSX). Windows and MacOSX boxes can be built locally with help of Hashicorp's [packer](https://www.packer.io/) tool. -!NOTE: To use MacOSX boxes you need an Apple-branded computer. +:small_red_triangle:NOTE: To use MacOSX boxes you need an Apple-branded computer. + +Additionally you need [vsts account url](https://www.visualstudio.com/en-us/get-started/setup/sign-up-for-visual-studio-online), username, [personal access token](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) and [pool name](http://blog.devmatter.com/understanding-pools-and-queues-in-vso/). + +Set environment variables + +on windows: +``` +set VSTS_URL=account.visualstudio.com +set VSTS_POOL=default +set VSTS_USER=username +set VSTS_TOKEN=my_secret_token_from_vsts +``` +on linux or macosx: +``` +export VSTS_URL=account.visualstudio.com +export VSTS_POOL=default +export VSTS_USER=username +export VSTS_TOKEN=my_secret_token_from_vsts +``` To run test against specific platform run: ``` diff --git a/providers/windows.rb b/providers/windows.rb index efb11dc..edf0db9 100644 --- a/providers/windows.rb +++ b/providers/windows.rb @@ -12,10 +12,8 @@ def load_current_resource @current_resource = Chef::Resource::VstsBuildAgentWindows.new(@new_resource.name) @current_resource.agent_name(@new_resource.agent_name) @current_resource.exists = false - load_current_state(@current_resource, node) @new_resource.sv_name(service_name(@new_resource)) - if agent_installed?(@current_resource, node) @current_resource.vsts_token(@new_resource.vsts_token) @current_resource.exists = true diff --git a/providers/xplat.rb b/providers/xplat.rb index 308360f..455e583 100644 --- a/providers/xplat.rb +++ b/providers/xplat.rb @@ -13,10 +13,8 @@ def load_current_resource @current_resource = Chef::Resource::VstsBuildAgentXplat.new(@new_resource.name) @current_resource.agent_name(@new_resource.agent_name) @current_resource.exists = false - load_current_state(@current_resource, node) @new_resource.sv_name(service_name(@new_resource)) - if agent_installed?(@current_resource, node) @current_resource.vsts_token(@new_resource.vsts_token) @current_resource.exists = true