GITLAB:将脚本输出保存在变量 .gitlab-ci.yml 中

时间:2021-03-30 06:14:48

标签: gitlab gitlab-ci

script:
        - ./scripts/getfilepath.py --unstripped ${BUILD_NUM}

gitlab-ci.yml 文件的这一部分。
我想将 getfilepath.py 的输出保存在一个变量中并稍后使用。

我尝试这样做:

script:
        - VER_PATH=`./scripts/getfilepath.py --unstripped ${BUILD_NUM}`

但这会保存文件中任何 print 语句的输出。

有没有办法只从脚本中获取返回值的结果?

这里是getfilepath.py的内容

def get_pdf():
    html_file = os.path.join(dirname, 'html_doc.html')
    pdf_file = os.path.join(dirname, 'pdf_doc.pdf')
    fill_html(sys.argv[1])
    convert_to_pdf(html_file, pdf_file)
    cleanup()
    return pdf_file 

1 个答案:

答案 0 :(得分:1)

我想您在跑步机中使用带有 shell = bash 的 shell executor

然后,这应该有效:

script:
  - VER_PATH=$(./scripts/getfilepath.py --unstripped ${BUILD_NUM})
相关问题