Skip to content
Advertisement

Zip command on Linux includes whole folder structure

I’m currently incorporating continuous integration on a project I’m working on at work using Bamboo. We are using ANT scripts to do the build automation, and as the final task we’re using the linux Zip command to create a release zip file. The problem is that the zip file contains the whole chain of folders leading up to the release folder which is not something I wish to include.

Currently I’m using the following ant call:

<exec executable="/usr/bin/zip" 
                  dir="${basedir}/tmp"
                  failonerror="true">
            <arg line="-r /var/...more directories.../repo/master/ProjectBuild/tmp/release.zip /var/...more directories.../repo/master/ProjectBuild/tmp/release -P PASSWORD_GOES_HERE" />
</exec>

This creates the right .zip file with right password but inside instead of having the folders and contents of /release folder I have the whole path which is /var/…more directories…/master…/release/. I tried using -j argument but that fails cause there are two files with same name in different sub-folders inside the release folder.

Is there any way I can include only the release folder contents inside the .zip file?

Advertisement

Answer

Have you tried that:

<exec executable="/usr/bin/zip" 
                  dir="/var/...more directories.../repo/master/ProjectBuild/tmp/"
                  failonerror="true">
    <arg line="-r /var/...more directories.../repo/master/ProjectBuild/tmp/release.zip release -P PASSWORD_GOES_HERE" />
</exec>

If you do not want to see the release top directory, you can try that:

<exec executable="/usr/bin/zip" 
                  dir="/var/...more directories.../repo/master/ProjectBuild/tmp/release"
                  failonerror="true">
    <arg line="-r /var/...more directories.../repo/master/ProjectBuild/tmp/release.zip . -P PASSWORD_GOES_HERE" />
</exec>
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement