Flavian Rotaru
Flavian Rotaru

Reputation: 1

Groovy throws file not found when tried to unzip a previously downloaded file

I'm trying to unzip a previously downloaded zip file to the branch and it's throwing the following error when unzipping it with antbuilder, and any other method suggested for unzipping in groovy:

[ERROR] Pipeline failed: src '/home/jenkins/workspace/XYZ/src/unpackaged.zip' doesn't exist.

Below is my code:

 static void unzipFile(Script script, String fileName, String dest = 'src', String overwrite = 'false'){

    def workspace = NodeUtils.getWorkspace(script)

    dest = "${workspace}"+ File.separator + "${dest}"
    def zipFile =  "${dest}" + File.separator + "${fileName}"

      def ant = new AntBuilder()
      ant.unzip(  src:"${zipFile}",
                  dest:"${dest}",
                  overwrite:"${overwrite}" )

  }

P.S, the workspace retrieval works as expected and it returns the correct path.

Upvotes: 0

Views: 229

Answers (0)

Related Questions