out="$(basename $(Build.ArtifactStagingDirectory)/*.zip)"
echo $out
curl -D- -u 'userid:token'-X POST-H 'X-Atlassian-Token: nocheck'-F 'file=@$(out)''confluence_url/rest/api/content/page_id/child/attachment'
Error curl: (26) Failed to open/read local data from file/application
If I add the file name it's working fine.
Hi @Saket Singh
Looking at the error output
./prog.sh: line 2: Build.ArtifactStagingDirectory: command not found./prog.sh: line 4: Build.ArtifactStagingDirectory: command not found./prog.sh: line 7: Output: command not found./prog.sh: line 8: /home/vsts/work/1/s: No such file or directory./prog.sh: line 9: total: command not found./prog.sh: line 10: -rw-r--r--: command not found./prog.sh: line 11: 269.zip: command not foundcurl: no URL specified!curl: try 'curl --help' or 'curl --manual' for more information./prog.sh: line 16: -X: command not found./prog.sh: line 17: -H: command not found./prog.sh: line 18: -F: command not found./prog.sh: line 21: Output-: command not found./prog.sh: line 22: syntax error near unexpected token `26'./prog.sh: line 22: `curl: (26) Failed to open/read local data from file/application'
There are errors from line 2 onwards. The issue isn't that the upload isn't working, but pretty much everything isn't working. You have output mixed in with shell commands.
Lines 7~11 and 21~23 are causing issues. Also, confluence_url isn't working, as that's not a valid URL.
I suggest cleaning up prog.sh first and then trying again.
James.
Make sure the file which is generated has only one zip file content.
Also when the file is referenced in API, can you make sure the file path which is given has an absolute path
Please try the above and let me know
Thanks
Hi @Pramodh M ,only 1 zip file is getting generated in the directory.I've provided the absolute path still getting the same error. Please refer to the below link for the updated command.https://ideone.com/0nZz1OThanks!
I'm looking at this again and I realise now the error you're using $() instead of ${} in the shell commands.
It should be something like this
And replace
with the correct values.
It's working now. Thanks James!
It looks like you're new here. Sign in or register to get started.