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

This part of gitlab-ci.yml file.
I want to save output of getfilepath.py in a variable and use it later.

I tried doing this:

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

But this saves the output of any print statements inside the file.

Is there a way to just get the result of the return value from the script?

Here is the content of 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 Answer 1

2

I suppose you use shell executor with shell = bash in your runner.

Then, this should work :

script:
  - VER_PATH=$(./scripts/getfilepath.py --unstripped ${BUILD_NUM})
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, Nicolas. I tried this, but no luck.
could you put the content of getfilepath.py in your question ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.