I am trying to pass the string to git page through api call from Pipeline run but getting some string formatting error
gitCheckInputString = '''{"name":"''' + gitCheckName + '''","output":{"title":"''' + gitCheckName + '''","summary":"''' + message + '''","text":"''' + "The summary:n{ unaudited: " + str($(params.unaudited)) + "n live: " + str($(params.live)) + "n real: " + str($(params.real)) + " }" + "n " + [Click on the link to see results on the Tekton build pipeline](''' + pipelineURL + ''') + '''"}}'''
print(gitCheckInputString)
SyntaxError: invalid syntax. Perhaps you forgot a comma?
The expected output is :
Click on the link to see results on the Tekton build
The summary:
{ unaudited: 10
live: 0
real: 9
}
2
Answers
”’ " is invalid you can’t put 2 string next to each other like that.
Maybe have a coma or a +. I am not sure because I don’t really understand what you are trying to do. Make your code a bit more readable and I am sure you will understand the issue yourself. It’s not a great practice to have big lines like these one. Try splitting it.
The error is here:
gitCheckName + '''","output"
Good morning friend, looking at your code is complicated, there are a lot of items inside a string, a lot (" "), (‘ ‘), (""" ""), this reference you are trying I don’t understand. But looking at first time, it looks like you’re trying to pass a dictionary or a json. I’m not sure if that would be it. But like the example you posted as an output, it looks like you’re trying to make a request, I’m not sure.
Well, I fixed it, an example dict:
result:
But as you said, you are trying to make a call, if so you will have to build a url, taking advantage of the previous dict with the parameters.
Using simple examples:
result:
‘https://yourlink.com/gitCheckName/gitCheckName’