{"user":"swce","name":"metadata-resource","namespace":"swce","repository_type":"image","status":1,"status_description":"active","description":"concourse-metadata-resource","is_private":false,"is_automated":true,"star_count":1,"pull_count":443473075,"last_updated":"2019-04-23T14:50:09.735863Z","last_modified":"2024-10-16T13:48:34.145251Z","date_registered":"2017-12-06T10:31:17.680548Z","collaborator_count":0,"affiliation":null,"hub_user":"swce","has_starred":false,"full_description":"\n[![Docker Stars](https://img.shields.io/docker/stars/swce/metadata-resource.svg?style=plastic)](https://registry.hub.docker.com/v2/repositories/swce/metadata-resource/stars/count/)\n[![Docker pulls](https://img.shields.io/docker/pulls/swce/metadata-resource.svg?style=plastic)](https://registry.hub.docker.com/v2/repositories/swce/metadata-resource)\n[![Docker build status](https://img.shields.io/docker/build/swce/metadata-resource.svg)](https://github.com/swce/metadata-resource)\n[![Docker Automated build](https://img.shields.io/docker/automated/swce/metadata-resource.svg)](https://github.com/swce/metadata-resource)\n\n[![dockeri.co](http://dockeri.co/image/swce/metadata-resource)](https://hub.docker.com/r/swce/metadata-resource/)\n\n# Concourse CI Metadata Resource\n\nImplements a resource that passes to a task the metadata of the job.\n\nCaution: misuse may result in angry concourse developers. This resource was created for the sole purpose of linking the Artifactory artifacts to the current build.\n\nOpinionated pipeline suggestion [here](#opinionated-pipeline)\n\n## Thanks\n\nThis resource was implemented based on the [build-metadata-resource](https://github.com/vito/build-metadata-resource)\n\n## Source Configuration\n\n``` YAML\nresource_types:\n  - name: meta\n    type: docker-image\n    source:\n      repository: swce/metadata-resource\n      \nresources:\n  - name: meta\n    type: meta\n```\n\n#### Parameters\n\n*None.*\n\n## Behavior\n\n### `check`: Produce a single dummy key\n\nProduce the current timestamp to invalidate the previous version so every build will get a fresh and relevant copy of the metadata.\n\n### `in`: Write the metadata to the destination dir\n\n - \"$BUILD_ID\" \u003e build-id\n - \"$BUILD_NAME\" \u003e build-name\n - \"$BUILD_JOB_NAME\" \u003e build-job-name\n - \"$BUILD_PIPELINE_NAME\" \u003e build-pipeline-name\n - \"$BUILD_TEAM_NAME\" \u003e build-team-name\n - \"$ATC_EXTERNAL_URL\" \u003e atc-external-url \n\n#### Parameters\n\n*None.*\n\n### `out`: Unused\n\nUnused\n\n#### Parameters\n\n*None.*\n\n## Examples\n\n```YAML\nresource_types:\n  - name: meta\n    type: docker-image\n    source:\n      repository: swce/metadata-resource\n\nresources:\n  - name: meta\n    type: meta\n\njobs:\n\n  - name: build\n    plan:\n      - get: meta\n      - task: build\n        file: tools/tasks/build/task.yml\n\n\n```\n\nThe build job gets in the `meta` dir all the files with the respected values in them to use as it pleases\n\n## Opinionated pipeline\n\nUse this resource to link the artifacts created by the build step to the current build. This is helpfull in a couple of ways: \n - Artifactory will show the build number in the metadata of the artifacts, which helps understanding which build created the artifacts.\n - When working with snapshots and production artifactory repositories, we can easily promote the artifacts of the build from snapshot to production without the need to realize all the artifacts created by the build and copying them one by one. This is done using the promote api call of Artifactory.\n \nWe will use the [keyval-resource](https://github.com/swce/keyval-resource) to pass the build number to the step that will release the artifact to production.\n\nThe `pipeline.yml` file:\n\n```YAML\nresource_types:\n  - name: meta\n    type: docker-image\n    source:\n      repository: swce/metadata-resource\n  - name: keyval\n    type: docker-image\n    source:\n      repository: swce/keyval-resource\n\nresources:\n  - name: meta\n    type: meta\n  - name: keyval\n    type: keyval\n\njobs:\n\n  - name: build\n    plan:\n      - get: meta\n      - task: build\n        file: tools/tasks/build/task.yml\n      - put: keyval\n        params:\n          file: keyvalout/keyval.properties\n\n...\n\n  - name: prod-deploy\n    plan:\n      - get: keyval\n      - task: prod-deploy\n        file: tools/tasks/prod-deploy/task.yml\n\n```\n\nThe `build` task:\n\n```sh\n\npipeline_id=`cat \"${ROOT_FOLDER}/meta/build-name\"`\necho \"Pipeline id is $pipeline_id\"\nexport \"PASSED_PIPELINE_ID=$pipeline_id\"\n\n...\n\ngradlew ... -PbuildId=\"${PASSED_PIPELINE_ID}\"\n\n```\n\nThe `build.gradle` file of the project:\n```gradle\n\nartifactory {\n  publish {\n    publishBuildInfo = true\n  }\n  clientConfig.info.setBuildNumber(buildId)\n  clientConfig.publisher.addMatrixParam(BuildInfoFields.BUILD_NUMBER, buildId)\n}\n\n```\n\nThe `prod-deploy` task:\n\n```sh\n  ...\n        echo \"Promoting build to production repo\"\n        local appName=$(retrieveAppName)\n        local args=\"{\\\"status\\\": \\\"Deployed\\\",\\\"comment\\\": \\\"moving to production\\\",\\\"copy\\\": true,\\\"sourceRepo\\\": \\\"${REPO_SNAPSHOT}\\\",\\\"targetRepo\\\": \\\"${REPO_RELEASE}\\\",\\\"properties\\\": {\\\"retention.pinned\\\":[\\\"7\\\"]}}\"\n        curl --fail -u \"${artifactory_user}:${artifactory_password}\" -H \"Content-Type: application/json\" -X POST -d \"'$args'\" \"${artifactory_contextUrl}/api/build/promote/${appName}/${PASSED_PIPELINE_ID}\"\n\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 metadata-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":81364842,"source":null}