Skip to content

Commit c9c073c

Browse files
chrisdibbledljvette
authored andcommitted
Adding --appspec-filename option description to bin/codedeploy-local, integration test cases covering custom appspec filename
1 parent 6beb142 commit c9c073c

File tree

7 files changed

+49
-4
lines changed

7 files changed

+49
-4
lines changed

bin/codedeploy-local

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Synopsis
5454
[--application-name <value>]
5555
[--events <value>]
5656
[--agent-configuration-file <value>]
57+
[--appspec-filename <value>]
5758
5859
Options
5960
*******
@@ -83,6 +84,9 @@ Options
8384
-c, --agent-configuration-file <value>
8485
The location of a configuration file to use for the deployment, if you store it in a location other than the default. A configuration file specifies alternatives to other default values and behaviors for a deployment. By default, configuration files are stored as /etc/codedeploy-agent/conf/codedeployagent.yml (Amazon Linux, RHEL, or Ubuntu Server instances) or C:/ProgramData/Amazon/CodeDeploy/conf.yml (Windows Server).
8586
87+
-A, --appspec-filename <value>
88+
The name of the appspec file to use for the deployment, if you set it to a name other than the default. By default, appspec files are named "appspec.yml" or "appspec.yaml".
89+
8690
-h, --help
8791
Displays a summary of help content.
8892

features/codedeploy-local/codedeploy_local.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,17 @@ Feature: Local Deploy using AWS CodeDeploy Local CLI
9393
When I create a local deployment with my bundle with file-exists-behavior RETAIN
9494
Then the local deployment command should succeed
9595
And the expected existing file should end up like file-exists-behavior RETAIN specifies
96+
97+
Scenario: Doing a sample local deployment using a directory bundle with a custom appspec filename
98+
Given I have a sample local directory bundle
99+
And I have a custom appspec filename appspec_override.yaml
100+
When I create a local deployment with my bundle
101+
Then the local deployment command should succeed
102+
And the expected files should have have been locally deployed to my host
103+
And the scripts should have been executed during local deployment
104+
105+
Scenario: Doing a sample local deployment using a directory bundle with a non-existent custom appspec filename
106+
Given I have a sample local directory bundle
107+
And I have a custom appspec filename appspec_nonexistent.yaml
108+
When I create a local deployment with my bundle
109+
Then the local deployment command should fail
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 0.0
2+
os: linux
3+
hooks:
4+
BeforeBlockTraffic:
5+
- location: scripts/before_block_traffic.sh
6+
AfterBlockTraffic:
7+
- location: scripts/after_block_traffic.sh
8+
ApplicationStop:
9+
- location: scripts/application_stop.sh
10+
BeforeInstall:
11+
- location: scripts/before_install.sh
12+
AfterInstall:
13+
- location: scripts/after_install.sh
14+
ApplicationStart:
15+
- location: scripts/application_start.sh
16+
ValidateService:
17+
- location: scripts/validate_service.sh
18+
BeforeAllowTraffic:
19+
- location: scripts/before_allow_traffic.sh
20+
AfterAllowTraffic:
21+
- location: scripts/after_allow_traffic.sh

features/step_definitions/codedeploy_local_steps.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Before("@codedeploy-local") do
1616
@test_directory = Dir.mktmpdir
1717
configure_local_agent(@test_directory)
18+
@appspec_filename = 'appspec.yml'
1819
end
1920

2021
After("@codedeploy-local") do
@@ -121,6 +122,10 @@ def tgz_app_bundle(temp_directory_to_create_bundle)
121122
tgz_file_name
122123
end
123124

125+
Given(/^I have a custom appspec filename ([^"]*)$/) do |custom_appspec_filename|
126+
@appspec_filename = custom_appspec_filename
127+
end
128+
124129
When(/^I create a local deployment with my bundle with only events (.+)$/) do |custom_events|
125130
@local_deployment_succeeded = create_local_deployment(custom_events.split(' '))
126131
end
@@ -148,7 +153,7 @@ def create_local_deployment(custom_events = nil, file_exists_behavior = nil)
148153
# Windows doesn't respect shebang lines so ruby needs to be specified
149154
ruby_prefix_for_windows = StepConstants::IS_WINDOWS ? "ruby " : ""
150155

151-
system "#{ruby_prefix_for_windows}bin/codedeploy-local --bundle-location #{@bundle_location} --type #{@bundle_type} --deployment-group #{LOCAL_DEPLOYMENT_GROUP_ID} --agent-configuration-file #{InstanceAgent::Config.config[:config_file]}#{codeedeploy_command_suffix}"
156+
system "#{ruby_prefix_for_windows}bin/codedeploy-local --bundle-location #{@bundle_location} --type #{@bundle_type} --deployment-group #{LOCAL_DEPLOYMENT_GROUP_ID} --agent-configuration-file #{InstanceAgent::Config.config[:config_file]}#{codeedeploy_command_suffix} --appspec-filename #{@appspec_filename}"
152157
end
153158

154159
Then(/^the local deployment command should succeed$/) do

features/step_definitions/common_steps.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def write_zip_entries(entries, path, input_dir, zip_io)
7878
expect(files_and_directories_in_deployment_id_folder).to include(*%w(logs deployment-archive))
7979

8080
files_and_directories_in_deployment_archive_folder = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentCommandTracker.directories_and_files_inside("#{InstanceAgent::Config.config[:root_dir]}/#{deployment_group_id}/#{deployment_id}/deployment-archive")
81-
expect(files_and_directories_in_deployment_archive_folder.size).to eq(2)
81+
# most sample apps contain 2 files that should be present, except the linux sample app which contains an additional appspec file with a custom filename
82+
expect(files_and_directories_in_deployment_archive_folder.size).to be_between(2, 3)
8283
expect(files_and_directories_in_deployment_archive_folder).to include(*%w(appspec.yml scripts))
8384

8485
files_in_scripts_folder = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentCommandTracker.directories_and_files_inside("#{InstanceAgent::Config.config[:root_dir]}/#{deployment_group_id}/#{deployment_id}/deployment-archive/scripts")

lib/aws/codedeploy/local/cli_validator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def validate(args)
4444
if !appspec_filename.nil? && !File.exists?("#{location}/#{appspec_filename}")
4545
raise ValidationError.new("Expecting appspec file at location #{location}/#{appspec_filename} but it is not found there. Please either run the CLI from within a directory containing the #{appspec_filename} file or specify a bundle location containing an #{appspec_filename} file in its root directory")
4646
end
47-
if !File.exists?("#{location}/appspec.yml") && !File.exists?("#{location}/appspec.yaml")
47+
if appspec_filename.nil? && !File.exists?("#{location}/appspec.yml") && !File.exists?("#{location}/appspec.yaml")
4848
raise ValidationError.new("Expecting appspec file at location #{location}/appspec.yml or #{location}/appspec.yaml but it is not found there. Please either run the CLI from within a directory containing the appspec.yml or appspec.yaml file or specify a bundle location containing an appspec.yml or appspec.yaml file in its root directory")
4949
end
5050
end

lib/instance_agent/plugins/codedeploy/deployment_specification.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,4 @@ def getDeploymentIdFromArn(arn)
175175
end
176176
end
177177
end
178-
end
178+
end

0 commit comments

Comments
 (0)