Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to upload zip file from Azure pipeline VM to Confluence page

Saket Singh March 3, 2022
I'm trying to upload a zip file present in the Azure pipeline VM to Confluence page

retrieving the file name

out="$(basename $(Build.ArtifactStagingDirectory)/*.zip)"

echo $out

Upload command

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.

3 answers

1 accepted

0 votes
Answer accepted
James Richards
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 23, 2022

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 found
curl: 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.

0 votes
James Richards
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 9, 2022

Hi @Saket Singh

 

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

  • userid
  • token
  • confluence_url
  • page_id

with the correct values.

  1. cd ${Build.ArtifactStagingDirectory}
  2. temp="$(basename ${Build.ArtifactStagingDirectory}/*.zip)"
  3.   
  4. curl -D- -u 'userid:token' \
  5. -X POST \
  6. -H 'X-Atlassian-Token: nocheck' \
  7. -F 'file=@"${Build.ArtifactStagingDirectory}/$temp"' \
  8. '${confluence_url}/rest/api/content/${page_id}/child/attachment'

James.

Saket Singh August 13, 2022

It's working now. Thanks James!

0 votes
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 3, 2022

Hi @Saket Singh 

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

Saket Singh March 3, 2022

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/0nZz1O

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events