Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Pipeline bat multiple lines

According to the docs, one can have multiple lines in the script paramater of bat

However, I've tried the following in my stage steps and only the first line gets executed

Declarative pipeline:

...
bat """
    c:\\path\\to\\conda activate my_env
    cd c:\\path\\to\\scripts
    python myscript.py ${some_arg}
"""
...

Scripted pipeline:

...
bat(
    returnStdout: true, 
    script: """
        c:\\path\\to\\conda activate my_env
        cd c:\\path\\to\\scripts
        python myscript.py ${some_arg}
    """
)
...

What do I need to do to get all the lines to execute sequentially?

p.s. I know I can chain the commands into a single line with "&" but that quickly becomes unreadable with lots of commands.

like image 612
Griffin Avatar asked Jun 11 '19 10:06

Griffin


1 Answers

You can add the keyword call, where ever you are running scripts in line, please follow below:-

...
bat """
    call c:\\path\\to\\conda activate my_env
    cd c:\\path\\to\\scripts
    call python myscript.py ${some_arg}
"""
...
like image 124
user_9090 Avatar answered Sep 20 '22 04:09

user_9090