最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Adding image name as variable in docker drone yml - Stack Overflow

programmeradmin1浏览0评论

I have a drone.yml that has multiple docker pipelines, and all of them have several steps that use the same image more than once. Instead of writing every single time:

- name: name_of_step
  image: name_of_image_written_manually

I want to declare a variable at the very top of the file so it can be updated much more easily in the future when new versions come out.

Right now I have the variable declaration like this:

variables:
  name_of_image: name_of_image_written_manually

kind: pipeline
type: docker
{rest of file}

But the problem arises when trying to use the variable. I've tried: image: $name_of_image, image: ${name_of_image}, image: ${{ name_of_image }}, image: ${{ variables.name_of_image }}. But I keep getting errors like 'invalid reference format', 'unable to parse variable name', and 'linter: invalid or missing image'.

I've tried to look for documentation but can't find a reliable answer for my specific case. I'm not even sure whether the problem is the variable declaration or the syntax of the variable use. For the variable declaration I've also tried:

global-variables:
  name_of_image: name_of_image_written_manually

and

variables:
  - name: name_of_image
  value: name_of_image_written_manually

Any help would be appreciated. Thanks in advance!

发布评论

评论列表(0)

  1. 暂无评论