How to create a Docker image based on a git tag in a shared registry?

I am building a continuous deployment strategy using Docker. My code is hosted on Github, and the Docker registry starts auto-build when I click on git. The default value is to start building when I click the wizard and create an image using the "last" tag. This is good, but I also want to be able to mark commits in git and create an image on it. It seems that there are some functions for this on the Docker registry site, on the "Edit Automated Assemblies" page, I can select the "tag" for the type and specify a static tag name.

How can I use the Docker tag name in the same way as the git tag name?

The goal is to be able to mark specific versions so that version history exists.

+6
source share
3 answers

This can be done in the Docker registry in the "Automatic build" settings. By default, this makes an assembly called "last" based on your "master" branch, but you can add automatic assemblies for specific git tags. The following figure shows the corresponding screen.

+2
source

The simplest command line solution is the git -rev nested command:

docker tag <image> <image>:$(git rev-parse --short HEAD)" 

gives you for example.

 <image> = myImage >> myImage:67df348 
+2
source

I have the same problem and I sorted it using this plugin:

https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin

This is not a pretty solution, but it works, so:

1) Run the shell: echo TAG=${GIT_BRANCH#*/} > docker_tag

2) Injective environment variables Properties File path: docker_tag

3) use ${TAG} at https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Build+and+Publish+plugin

0
source

Source: https://habr.com/ru/post/976963/


All Articles