{"user":"swce","name":"keyval-resource","namespace":"swce","repository_type":"image","status":1,"status_description":"active","description":"Implements a resource that passes key values between jobs without using any external resource","is_private":false,"is_automated":true,"star_count":3,"pull_count":474556902,"last_updated":"2018-01-15T09:13:26.776947Z","last_modified":"2024-10-16T13:48:34.145251Z","date_registered":"2017-11-21T10:46:41.119914Z","collaborator_count":0,"affiliation":null,"hub_user":"swce","has_starred":false,"full_description":"\n[![Docker Stars](https://img.shields.io/docker/stars/swce/keyval-resource.svg?style=plastic)](https://registry.hub.docker.com/v2/repositories/swce/keyval-resource/stars/count/)\n[![Docker pulls](https://img.shields.io/docker/pulls/swce/keyval-resource.svg?style=plastic)](https://registry.hub.docker.com/v2/repositories/swce/keyval-resource)\n[![Docker build status](https://img.shields.io/docker/build/swce/keyval-resource.svg)](https://github.com/swce/keyval-resource)\n[![Docker Automated build](https://img.shields.io/docker/automated/swce/keyval-resource.svg)](https://github.com/swce/keyval-resource)\n\n[![dockeri.co](http://dockeri.co/image/swce/keyval-resource)](https://hub.docker.com/r/swce/keyval-resource/)\n\n# Concourse CI Key Value Resource\n\nImplements a resource that passes key values between jobs without using any external resource such as git/s3 etc.\n\n## Thanks\n\nThis resource was implemented based on the [time resource](https://github.com/concourse/time-resource)\n\n## Source Configuration\n\n``` YAML\nresource_types:\n  - name: keyval\n    type: docker-image\n    source:\n      repository: swce/keyval-resource\n      \nresources:\n  - name: keyval\n    type: keyval\n```\n\n#### Parameters\n\n*None.*\n\n## Behavior\n\n### `check`: Produce a single dummy key\n\nThis is a version-less resource so `check` behavior is no-op\n\n### `in`: Report the given time.\n\nFetches the given key values and stores them in the `keyval.properties` file.\nThe format is of a `.properties` file, e.g. `\"\u003ckey\u003e=\u003cvalue\u003e\"`.\n\n#### Parameters\n\n*None.*\n\n### `out`: Consumes the given properties file\n\n``` YAML\n- put: keyval\n  params:\n    file: keyvalout/keyval.properties\n```\n\nReads the given properties file and sets them for the next job.\n\n#### Parameters\n- file - the properties file to read the key values from\n\n## Examples\n\n```YAML\nresource_types:\n  - name: keyval\n    type: docker-image\n    source:\n      repository: swce/keyval-resource\n\nresources:\n  - name: keyval\n    type: keyval\n\njobs:\n\n  - name: build\n    plan:\n      - task: build\n        file: tools/tasks/build/task.yml\n      - put: keyval\n        params:\n          file: keyvalout/keyval.properties\n\n  - name: test-deploy\n    plan:\n      - aggregate:\n        - get: keyval\n          passed:\n          - build\n      - task: test-deploy\n        file: tools/tasks/task.yml\n```\n\nThe build job writes all the key values it needs to pass along (e.g. artifact id) in the `keyvalout/keyval.properties` file. \nThe test-deploy can read the data from the `keyval/keyval.properties` file and use them as it pleases. \n\n## CI suggestions\n\n### Auto export the keys\n\nYou can add the following bash script to the **start** of every job to auto export the passed key values, if they exist. \nThe script assumes that the resource folder is `keyval`. \n\n* Don't forget to source the script so it's exports will be passed along\n\n```bash\n#!/bin/bash\n\nprops=\"${ROOT_FOLDER}/keyval/keyval.properties\"\nif [ -f \"$props\" ]\nthen\n  echo \"Reading passed key values\"\n  while IFS= read -r var\n  do\n    if [ ! -z \"$var\" ]\n    then\n      echo \"Adding: $var\"\n      export \"$var\"\n    fi\n  done \u003c \"$props\"\nfi\n\n```\n\n### Auto pass the keys\n\nYou can add the following bash script to the **end** of every job to auto pass specific environment variables as key values to the next job. \nThe script only passes environment variables that start with `PASSED_`. \nThe script assumes that the resource out file is `keyvalout/keyval.properties`:\n\ne.g. \n```YAML\n- put: keyval\n  params:\n    file: keyvalout/keyval.properties\n``` \n\n```bash\n#!/bin/bash\n\npropsDir=\"${ROOT_FOLDER}/keyvalout\"\npropsFile=\"${propsDir}/keyval.properties\"\nif [ -d \"$propsDir\" ]\nthen\n  touch \"$propsFile\"\n  echo \"Setting key values for next job in ${propsFile}\"\n  while IFS='=' read -r name value ; do\n    if [[ $name == 'PASSED_'* ]]; then\n      echo \"Adding: ${name}=${value}\"\n      echo \"${name}=${value}\" \u003e\u003e \"$propsFile\"\n    fi\n  done \u003c \u003c(env)\nfi\n\n```\n\n## Development\n\n### Prerequisites\n\n* golang is *required* - version 1.9.x is tested; earlier versions may also\n  work.\n* docker is *required* - version 17.06.x is tested; earlier versions may also\n  work.\n* godep is used for dependency management of the golang packages.\n\n### Running the tests\n\nThe tests have been embedded with the `Dockerfile`; ensuring that the testing\nenvironment is consistent across any `docker` enabled platform. When the docker\nimage builds, the test are run inside the docker container, on failure they\nwill stop the build.\n\nRun the tests with the following command:\n\n```sh\ndocker build -t keyval-resource .\n```\n\n### Contributing\n\nPlease make all pull requests to the `master` branch and ensure tests pass\nlocally.\n","permissions":{"read":true,"write":false,"admin":false},"media_types":["application/vnd.docker.container.image.v1+json"],"content_types":["image"],"categories":[],"immutable_tags_settings":{"enabled":false,"rules":[".*"]},"storage_size":59523651,"source":null}