[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] gitlab-ci: Only push Docker 'latest' image when building def
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch |
Date: |
Tue, 16 Feb 2021 09:52:43 +0000 |
User-agent: |
Mutt/2.0.5 (2021-01-21) |
On Tue, Feb 16, 2021 at 08:05:09AM +0100, Philippe Mathieu-Daudé wrote:
> On 2/16/21 7:55 AM, Thomas Huth wrote:
> > On 15/02/2021 20.28, Philippe Mathieu-Daudé wrote:
> >> While we are interested in building docker images in different
> >> branches, it only makes sense to push 'latest' to the registry
> >> when this is the project default branch (usually 'master').
> >>
> >> Else when pushing different branches concurrently we might have
> >> inconsistent image state between branches.
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >> ---
> >> .gitlab-ci.d/containers.yml | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml
> >> index 90fac85ce46..52a915f4141 100644
> >> --- a/.gitlab-ci.d/containers.yml
> >> +++ b/.gitlab-ci.d/containers.yml
> >> @@ -17,7 +17,7 @@
> >> -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
> >> -r $CI_REGISTRY_IMAGE
> >> - docker tag "qemu/$NAME" "$TAG"
> >> - - docker push "$TAG"
> >> + - test "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" && docker push
> >> "$TAG"
> >
> > So does that mean that the following stages in the CI (i.e. build, test)
> > are only always (i.e. also for the non-master branches) going to use
> > containers that have been build on the master branch?
>
> Hmm good point. Should we use "$CI_COMMIT_BRANCH" instead of "latest"?
This doesn't work because git branch names are not guaranteed to be
valid docker tag names. Please see my thread here:
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg03535.html
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|