Per our IT department, I have to use a curl command to upload files to our SFTP server.
I use a Jenkins pipeline to build our artifacts on Windows build nodes, which are *.zip
files, and this is the curl
command I use
C:\> curl -V
curl 7.03.1 (Windows) libcurl/7.03.1 Schannel
C:\> curl -T ./build_artifact.zip -u 'user:password' ftp://ftp.company.com/devops/test/build_artifact.zip --ftp-ssl-reqd --ftp-create-dirs -k
The file uploads correctly.
But when I download the file on my Mac and I unzip it, I get
$ unzip build_artifact.zip
Archive: build_artifact.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of build_artifact.zip or
build_artifact.zip.zip, and cannot find build_artifact.zip.ZIP, period.
Note if I execute the same curl
command on my Mac to upload to the SFTP site, I can readily unzip the artifact when I subsequently download it.
Any clues on why this happens, and how to fix it?
./build_artifact.zip
for example, might the command be running from a different start folder, which means the relative path doesn't point to a file? One quick check for this would be to look at the size of the file. If it's 0 bytes, you might be uploading "file not found", if that makes sense.dir(env.WORKSPACE) {}
before I execute thecurl
command, and theWORKSPACE
is where thebuild_artifact.zip
file is.