Post

4 followers Follow
0
Avatar

How to deploy a tar (ideally tar.gz/.tgz) file and expand it in one go

I am deploying to Linux and want to preserve file permissions - so prefer to use tar over zip.

When I use a zip file with a file.Folder deployable, it does as expected - copies the zip file and expands into the targetPath

I see tar should be supported from this post - http://rabo.coop/xld1 (apologies for using a shortener, but copy/paste does not work for me in IE in this box)

However its not working for me.

XL deploy deployment says its "Done", but there is nothing in the targetPath.

It seems like its done nothing - no delete/copy entries, just update the repo is shown.

We are on v5.5.5

Thanks for any info.

Regards, Chris.

Chris Kimpton

Please sign in to leave a comment.

9 comments

0
Avatar

Response from XebiaLabs

"The file.Folder type supports only zip files. Tar files are not supported."

Chris Kimpton 0 votes
1
Avatar

Hi Chris,

You can use this community plugin, https://github.com/xebialabs-community/xld-folder-plugin

which you can download it from this link: https://github.com/xebialabs-community/xld-folder-plugin/releases/download/v0.0.1/xld-folder-plugin-0.0.1.xldp

You will see below in it's readme file,

xld.Folder: A folder uploaded as an archive and copied to the target host as an archive. Extracted on the target host.

  • On linux: zip, gzip, bzip2 and tar are supported.
  • On windows: zip is supported.

Regards,

Ibrahim

Ibrahim Elshal 1 vote
0
Avatar

Hi Ibrahim - please ignore my comments.

 

I see its using shell script on Linux and does not currently support tgz.

Will see if I can do a pull request :)

Chris Kimpton 0 votes
1
Avatar

I found that with a slight change to the plugin's create script (unpack_create.sh.ftl) it will support tgz. 

If you create a directory  <XLD_HOME>/ext/xld.Folder and add to that unpack_create.sh.ftl text below it will handle tgz. 

#!/bin/bash

set -e

 

FILE_TYPE=`file --mime-type -b ${deployed.file.path}`

 

echo "The file type is $FILE_TYPE"

 

if [[ $FILE_TYPE == "application/zip" ]]; then

    /usr/bin/unzip -o "${deployed.file.path}" -d "${deployed.targetPath}"

elif [[ $FILE_TYPE == "application/x-gzip" || $FILE_TYPE == "application/gzip" ]]; then

    /bin/tar -xvz -C "${deployed.targetPath}" -f "${deployed.file.path}"

elif [[ $FILE_TYPE == "application/x-bzip2" || $FILE_TYPE == "application/bzip2" ]]; then

    /bin/tar -xvj -C "${deployed.targetPath}" -f "${deployed.file.path}"

elif [[ $FILE_TYPE == "application/x-tar" || $FILE_TYPE == "application/tar" ]]; then

    /bin/tar -xv -C "${deployed.targetPath}" -f "${deployed.file.path}"

 elif [[ $FILE_TYPE == "application/x-gtar" || $FILE_TYPE == "application/x-gtar" ]]; then

    /bin/tar -xvf -C "${deployed.targetPath}" -f "${deployed.file.path}"

fi

 

 

 

Daniel Robichau 1 vote
0
Avatar

Thanks Daniel - however, tgz files seem to be working just fine without modifying the xld-folder plugin for me :).

Chris Kimpton 0 votes
0
Avatar

We have tried to deploy a tar file and XL deploy appears to be transferring the tar file to /tmp and then updates the timestamp of the directory specified in the target path.  There is no check or update  or extract of the contents of the tar contents to the target path.

Why would this happen?  Should we change back to a zip file?

Thanks!

--glenn

glenn opdycke 0 votes