Issue
In Jenkins I'm calling a python script to do some magic actions. The pipeline is in production state for some time now and suddenly for one developer branch I'm getting
Syntax error: Unterminated quoted string
constanly this Error in Jenkins.
The causing snippet seems to be this one:
sh """
. .venv/bin/activate
python3 -m some_python_package.some_sub_package.script --stage update_something \
--api PROD '$SOME_ID' '$SOME_TOKEN' --user_id ${env.CHANGE_AUTHOR_DISPLAY_NAME} --file_list ${validFilePath} 2>&1 | tee output/log.txt
"""
I already tried different escaping methods, but also this one did not help, same error message remains:
sh """
. .venv/bin/activate
python3 -m some_python_package.some_sub_package.script --stage update_something \
--api PROD \'$SOME_ID\' \'$SOME_TOKEN\' --user_id ${env.CHANGE_AUTHOR_DISPLAY_NAME} --file_list ${validFilePath} 2>&1 | tee output/log.txt
"""
Solution
Actually a very stupid case. As mentioned by @pmod one of the variables in file_list had a ' contained in a string, which messed up the shell comand... So the shell comand in the Jenkins file was correct, but I have to take care that the input values are correct as well in future
Answered By - Scf_suedbaden Answer Checked By - David Marino (WPSolving Volunteer)