1.0.3 • Published 5 years ago

gitlab-get-docker-image-version v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

gitlab-get-docker-image-version

Get version tag of docker image from provided commit tag. It is designed to be used with gitlab runner for determining docker image version in deploy stage.

Usage

$ export RUNNER_TOKEN=<Personal Access Token>
$ export REPO_HOST=<Repo URL>
$ export CI_PROJECT_URL=<Project URL>
$ gitlab-get-docker-image-version <SHA Commit Tag>

or

$ export RUNNER_TOKEN=<Personal Access Token>
$ export REPO_HOST=<Repo URL>
$ export CI_PROJECT_URL=<Project URL>
$ export CI_COMMIT_SHA=<SHA Commit Tag>
$ gitlab-get-docker-image-version

Environment variables

Env NameDescriptionRequired
RUNNER_TOKENPersonal Access Token with read_registry accessRequired
REPO_HOSTRepo URL, i.e. https://git.example.comRequired
CI_PROJECT_URLProject URL, i.e. https://git.example.com/my-group/my-projectRequired
CI_COMMIT_SHASHA Commit TagOptional

Example

Assumptions

  1. Registry: docker.example.com
  2. Image name: my-group/my-project
  3. Available tags

    Tag nameTag ID
    1.0.0aaaaaa
    some-sha-commit-aaaaaaa
    1.0.1bbbbbb
    some-sha-commit-bbbbbbb
    latestbbbbbb
$ export RUNNER_TOKEN=1234
$ export REPO_HOST=https://git.example.com
$ export CI_PROJECT_URL=https://git.example.com/my-group/my-project
$ export CI_COMMIT_SHA=some-sha-commit-a
$ gitlab-get-docker-image-version
1.0.0
$ gitlab-get-docker-image-version some-sha-commit-b
1.0.1

MIT License

Copyright 2018 Attawit Kittikrairit

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.