在drone.io中的步骤之间共享变量

时间:2019-01-23 13:33:51

标签: continuous-integration drone.io shared-variable

在我看来,drone.io不会跨管道步骤共享参数。 是否可以从文件中读取插件的参数,例如指令 像“ from_file”类似于已经存在的“ from_secret”?这样可以使用它:

kind: pipeline
name: default

steps:
- name: get_repo_name
  image: alpine
  commands:
  - echo "hello" > .repo_name
- name: docker  
  image: plugins/docker
  settings:
    repo: 
      from_file: .repo_name
    username:
      from_secret: docker_username
    password:
      from_secret: docker_password

1 个答案:

答案 0 :(得分:1)

从文件中读取输入的能力更多地由插件作者选择,但是创建插件是一件非常简单的事情,因为大多数变量只需要以PLUGIN_VARIABLE的形式调用,然后您可以提供东西。

为证明某些插件确实可以从文件中读取内容,其中一个示例是drone-github-comment:

steps:
- name: github-comment
  image: jmccann/drone-github-comment:1.2
  settings:
    message_file: file_name.txt
  when:
    status:
    - success
    - failure

FWIW,尽管看您的示例,看来您只是想传递repo_name吗?这些变量全部存在于管道中,具体取决于您所使用的运行程序,但是对于Docker,您可以获得所有这些变量: