concourseのresource-typeのサンプルです。
1.0K
最小限のconcourseのresource-typeを実装します。 詳しくは、Implementing a Resourceのドキュメントを参照下さい。
resource typeとresourceを下記のように定義します。
resource_types:
- name: cloudformation
type: docker-image
source:
repository: ksaito1125/cloudformation-resource-type
tag: work
resources:
- name: test-concourse-1
type: cloudformation
source:
region_name: ap-northeast-1
access_key_id: {{aws_access_key_id}}
secret_access_key: {{aws_secret_access_key}}
cacert: http://www.iss.toshiba.co.jp/services/ss/ca/manual/certificate/toshibaca.cer
パイプラインのputでparamsにスタック名、テンプレートファイル、パラメータを指定します。
- put: test-concourse-1
params:
cloudformation_file: out/sg.yaml
stack_name: test-concourse-1
parameters:
Port: 82
Host: server1
下記の手順でビルドとテストを実行します。
make test
$ make test
docker build -t sample-resource-type .
Sending build context to Docker daemon 85.5kB
Step 1/2 : FROM alpine:3.7
---> 3fd9065eaf02
Step 2/2 : COPY assets /opt/resource
---> Using cache
---> 6f403114ce46
Successfully built 6f403114ce46
Successfully tagged sample-resource-type:latest
docker run -it --rm sample-resource-type sh -c "echo aaa | /opt/resource/check"
[
{ "ref": "61cbef" },
{ "ref": "d74e01" },
{ "ref": "7154fe" }
]
docker run -it --rm sample-resource-type sh -c "echo aaa | /opt/resource/in"
{
"version": { "ref": "61cebf" },
"metadata": [
{ "name": "commit", "value": "61cebf" },
{ "name": "author", "value": "Hulk Hogan" }
]
}
docker run -it --rm sample-resource-type sh -c "echo aaa | /opt/resource/out"
{
"version": { "ref": "61cebf" },
"metadata": [
{ "name": "commit", "value": "61cebf" },
{ "name": "author", "value": "Mick Foley" }
]
$
masterにpushするとDockerHubでコンテナがビルドされます。
DockerHubでビルドされたsample-resource-typeを、下記の手順でconcourseでテストします。
make it
実行例は、以下の通りです。
$ make it
fly -t test set-pipeline -n -p sample-resource-type -c pipeline.yaml
configuration updated
fly -t test unpause-pipeline -p sample-resource-type
unpaused 'sample-resource-type'
fly -t test trigger-job -w -j sample-resource-type/sample
started sample-resource-type/sample #9
succeeded
fly -t test intercept -j sample-resource-type/sample sh
1: build #8, step: sample-resource, type: put
2: build #9, step: sample-resource, type: get
3: build #9, step: sample-resource, type: put
choose a container:
以上
Content type
Image
Digest
Size
26.9 MB
Last updated
over 8 years ago
docker pull ksaito1125/sample-resource-type