All Projects → SWCE → keyval-resource

SWCE / keyval-resource

Licence: Apache-2.0 license
a resource that passes key values between jobs

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to keyval-resource

ofcourse
A Concourse resource generator
Stars: ✭ 41 (+5.13%)
Mutual labels:  ci, concourse, concourse-ci
Dictionary
A dictionary data type with a fast b-tree based search
Stars: ✭ 39 (+0%)
Mutual labels:  key-value, value, key
bender
A Concourse resource that can trigger and pass parameters to jobs using slack
Stars: ✭ 32 (-17.95%)
Mutual labels:  concourse, concourse-ci
concourse-git-bitbucket-pr-resource
🚀 Concourse CI resource for tracking git branches of Bitbucket pull-requests
Stars: ✭ 29 (-25.64%)
Mutual labels:  concourse, concourse-ci
Concourse
Concourse is a container-based continuous thing-doer written in Go.
Stars: ✭ 6,070 (+15464.1%)
Mutual labels:  ci, concourse
terraform-aws-concourse
Terraform Module for a distributed concourse cluster on AWS
Stars: ✭ 12 (-69.23%)
Mutual labels:  concourse, concourse-ci
tool-db
A peer-to-peer decentralized database
Stars: ✭ 15 (-61.54%)
Mutual labels:  value, key
concourse-slack-alert-resource
A structured Slack notification resource for Concourse
Stars: ✭ 41 (+5.13%)
Mutual labels:  resource, concourse
ansible-concourse
An ansible role to manage Concourse CI
Stars: ✭ 22 (-43.59%)
Mutual labels:  concourse, concourse-ci
DataTanker
Embedded persistent key-value store for .NET. Pure C# code.
Stars: ✭ 53 (+35.9%)
Mutual labels:  key-value, keyvalue
concourse-fly-resource
A Concourse resource for manipulating fly
Stars: ✭ 16 (-58.97%)
Mutual labels:  concourse, concourse-ci
concourse-build-resource
A Concourse resource for observing Concourse builds
Stars: ✭ 16 (-58.97%)
Mutual labels:  concourse, concourse-ci
comment-value
Instruments a Node program and updates its comments with computed expression values
Stars: ✭ 27 (-30.77%)
Mutual labels:  value
prebuild-ci
Use CI to auto upload prebuilds
Stars: ✭ 17 (-56.41%)
Mutual labels:  ci
steps-carthage
Step for building dependencies with Carthage on Bitrise
Stars: ✭ 14 (-64.1%)
Mutual labels:  ci
kubedock
Kubedock is a minimal implementation of the docker api that will orchestrate containers on a Kubernetes cluster, rather than running containers locally.
Stars: ✭ 79 (+102.56%)
Mutual labels:  ci
documentation
📚 Documentation for GameCI open source projects
Stars: ✭ 96 (+146.15%)
Mutual labels:  ci
vdf-parser
📜 Libraries to (de)serialize Valve's KeyValue format (VDF) in various languages
Stars: ✭ 70 (+79.49%)
Mutual labels:  keyvalue
npm-groovy-lint
Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files using command line
Stars: ✭ 124 (+217.95%)
Mutual labels:  ci
xjtlu resource list
A resource list for student in XJTLU.
Stars: ✭ 21 (-46.15%)
Mutual labels:  resource

Docker Stars Docker pulls Docker build status Docker Automated build

dockeri.co

Concourse CI Key Value Resource

Implements a resource that passes key values between jobs without using any external resource such as git/s3 etc.

Thanks

This resource was implemented based on the time resource

Source Configuration

resource_types:
  - name: keyval
    type: docker-image
    source:
      repository: swce/keyval-resource
      
resources:
  - name: keyval
    type: keyval

Parameters

None.

Behavior

check: Produce a single dummy key

This is a version-less resource so check behavior is no-op

in: Report the given time.

Fetches the given key values and stores them in the keyval.properties file. The format is of a .properties file, e.g. "<key>=<value>".

Parameters

None.

out: Consumes the given properties file

- put: keyval
  params:
    file: keyvalout/keyval.properties

Reads the given properties file and sets them for the next job.

Parameters

  • file - the properties file to read the key values from

Examples

resource_types:
  - name: keyval
    type: docker-image
    source:
      repository: swce/keyval-resource

resources:
  - name: keyval
    type: keyval

jobs:

  - name: build
    plan:
      - task: build
        file: tools/tasks/build/task.yml
      - put: keyval
        params:
          file: keyvalout/keyval.properties

  - name: test-deploy
    plan:
      - aggregate:
        - get: keyval
          passed:
          - build
      - task: test-deploy
        file: tools/tasks/task.yml

The build job writes all the key values it needs to pass along (e.g. artifact id) in the keyvalout/keyval.properties file. The test-deploy can read the data from the keyval/keyval.properties file and use them as it pleases.

CI suggestions

Auto export the keys

You can add the following bash script to the start of every job to auto export the passed key values, if they exist. The script assumes that the resource folder is keyval.

  • Don't forget to source the script so it's exports will be passed along
#!/bin/bash

props="${ROOT_FOLDER}/keyval/keyval.properties"
if [ -f "$props" ]
then
  echo "Reading passed key values"
  while IFS= read -r var
  do
    if [ ! -z "$var" ]
    then
      echo "Adding: $var"
      export "$var"
    fi
  done < "$props"
fi

Auto pass the keys

You 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. The script only passes environment variables that start with PASSED_. The script assumes that the resource out file is keyvalout/keyval.properties:

e.g.

- put: keyval
  params:
    file: keyvalout/keyval.properties
#!/bin/bash

propsDir="${ROOT_FOLDER}/keyvalout"
propsFile="${propsDir}/keyval.properties"
if [ -d "$propsDir" ]
then
  touch "$propsFile"
  echo "Setting key values for next job in ${propsFile}"
  while IFS='=' read -r name value ; do
    if [[ $name == 'PASSED_'* ]]; then
      echo "Adding: ${name}=${value}"
      echo "${name}=${value}" >> "$propsFile"
    fi
  done < <(env)
fi

Development

Prerequisites

  • golang is required - version 1.9.x is tested; earlier versions may also work.
  • docker is required - version 17.06.x is tested; earlier versions may also work.
  • godep is used for dependency management of the golang packages.

Running the tests

The tests have been embedded with the Dockerfile; ensuring that the testing environment is consistent across any docker enabled platform. When the docker image builds, the test are run inside the docker container, on failure they will stop the build.

Run the tests with the following command:

docker build -t keyval-resource .

Contributing

Please make all pull requests to the master branch and ensure tests pass locally.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].