Ciinabox Jenkins Pipeline Updates
This update adds some extra functionality to some AMI baking methods around AMI lookup from SSM parameters as well as additional chef options to the AMI verify method.
lookupAMI
- look up ami from ssm parameter
- override default environment variable
SOURCE_AMI
withenv:
option
step {
lookupAMI(
region: 'ap-southeast-2',
ssm: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs',
env: 'MY_AMI_ID'
)
echo "found latest amazon linux 2 AMI: ${MY_AMI_ID}"
}
packer
- refactor AMI lookup from SSM code to use
lookupAMI()
method - output 2 new environment variables for the AMI name
env["${ROLE}_BAKED_NAME"]
and the bake idenv["${ROLE}_BAKED_ID"]
where${ROLE}
is the uppercase value of therole:
parameter passed into the packer method.
verifyAMIv2
- support AMI lookup to allow testing before baking AMI
- add runlist parameter to run a list of recipes from the cookbook before running the inspec tests
- accept chef license
- destroy instance at the end of the run
The following example spins up a base amazon linux 2 AMI and runs the my-cookbook::app
recipe before validating the inspec test suite amzn2
. This allows the ability to run your inspec tests before baking the AMI with packer
steps {
verifyAMIv2(
role: 'App',
cookbook: 'my-cookbook',
amiLookupSSM: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs',
suite: 'amzn2',
runlist: ['app']
)
}
PR: https://github.com/base2Services/ciinabox-pipelines/pull/117