Skip to content

Commit

Permalink
Merge pull request #108 from falkena/feature/AddTGZStep
Browse files Browse the repository at this point in the history
Introduce tar/untar steps including gzip compression.
  • Loading branch information
rsandell committed Nov 29, 2021
2 parents 08d61a0 + cf2d7cc commit 492925e
Show file tree
Hide file tree
Showing 40 changed files with 2,076 additions and 376 deletions.
4 changes: 4 additions & 0 deletions docs/STEPS.md
Expand Up @@ -10,6 +10,10 @@
* `verifySha256` - Verifies the SHA-256 of a given file. ([help](../src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/fs/FileVerifySha256Step/help.html))
* `tee` - Tee output to file

### Tar/tar.gz/tgz Files
* `tar` - Create Tar file. ([help](../src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/tar/TarStep/help.html))
* `untar` - Extract Tar file ([help](../src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/tar/UnTarStep/help.html))

### Zip Files
* `zip` - Create Zip file. ([help](../src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/zip/ZipStep/help.html))
* `unzip` - Extract/Read Zip file ([help](../src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/zip/UnZipStep/help.html))
Expand Down
@@ -0,0 +1,40 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 CloudBees Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package org.jenkinsci.plugins.pipeline.utility.steps;

import hudson.FilePath;
import jenkins.MasterToSlaveFileCallable;

public abstract class AbstractFileCallable<T> extends MasterToSlaveFileCallable<T> {
private FilePath destination;

public FilePath getDestination() {
return destination;
}

public void setDestination(FilePath destination) {
this.destination = destination;
}
}
@@ -0,0 +1,117 @@
package org.jenkinsci.plugins.pipeline.utility.steps;

import org.kohsuke.stapler.DataBoundSetter;

public abstract class AbstractFileCompressStep extends AbstractFileStep {
private String dir;
private String glob;
private String exclude;
private boolean archive = false;
private boolean overwrite = false;

/**
* The relative path of the base directory to create the archive from.
* Leave empty to create from the current working directory.
*
* @return the dir
*/
public String getDir() {
return dir;
}

/**
* The relative path of the base directory to create the archive from.
* Leave empty to create from the current working directory.
*
* @param dir the dir
*/
@DataBoundSetter
public void setDir(String dir) {
this.dir = dir;
}

/**
* <a href="https://ant.apache.org/manual/dirtasks.html#patterns" target="_blank">Ant style pattern</a>
* of files to include in the archive.
* Leave empty to include all files and directories.
*
* @return the include pattern
*/
public String getGlob() {
return glob;
}

/**
* <a href="https://ant.apache.org/manual/dirtasks.html#patterns" target="_blank">Ant style pattern</a>
* of files to include in the archive.
* Leave empty to include all files and directories.
*
* @param glob the include pattern
*/
@DataBoundSetter
public void setGlob(String glob) {
this.glob = glob;
}

/**
* <a href="https://ant.apache.org/manual/dirtasks.html#patterns" target="_blank">Ant style pattern</a>
* of files to exclude from the archive.
*
* @return the exclude pattern
*/
public String getExclude() {
return exclude;
}

/**
* <a href="https://ant.apache.org/manual/dirtasks.html#patterns" target="_blank">Ant style pattern</a>
* of files to exclude in the archive.
*
* @param exclude the exclude pattern
*/
@DataBoundSetter
public void setExclude(String exclude) {
this.exclude = exclude;
}

/**
* If the archive file should be archived as an artifact of the current build.
* The file will still be kept in the workspace after archiving.
*
* @return if it should be archived or not
*/
public boolean isArchive() {
return archive;
}

/**
* If the archive file should be archived as an artifact of the current build.
* The file will still be kept in the workspace after archiving.
*
* @param archive if it should be archived or not
*/
@DataBoundSetter
public void setArchive(boolean archive) {
this.archive = archive;
}

/**
* If the archive file should be overwritten in case of already existing a file with the same name.
*
* @return if the file should be overwritten or not in case of existing.
*/
public boolean isOverwrite() {
return overwrite;
}

/**
* If the archive file should be overwritten in case of already existing a file with the same name.
*
* @param overwrite if the file should be overwritten or not in case of existing.
*/
@DataBoundSetter
public void setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
}

}
@@ -0,0 +1,99 @@
package org.jenkinsci.plugins.pipeline.utility.steps;

import org.kohsuke.stapler.DataBoundSetter;

public abstract class AbstractFileDecompressStep extends AbstractFileStep {
private String dir;
private String glob;
private boolean test = false;
private boolean quiet = false;

/**
* The relative path of the base directory to create the archive from.
* Leave empty to create from the current working directory.
*
* @return the dir
*/
public String getDir() {
return dir;
}

/**
* The relative path of the base directory to create the archive from.
* Leave empty to create from the current working directory.
*
* @param dir the dir
*/
@DataBoundSetter
public void setDir(String dir) {
this.dir = dir;
}

/**
* <a href="https://ant.apache.org/manual/dirtasks.html#patterns" target="_blank">Ant style pattern</a>
* of files to extract from the archive.
* Leave empty to include all files and directories.
*
* @return the include pattern
*/
public String getGlob() {
return glob;
}

/**
* <a href="https://ant.apache.org/manual/dirtasks.html#patterns" target="_blank">Ant style pattern</a>
* of files to extract from the archive.
* Leave empty to include all files and directories.
*
* @param glob the include pattern
*/
@DataBoundSetter
public void setGlob(String glob) {
this.glob = glob;
}

/**
* Test the integrity of the archive instead of extracting it.
* When this parameter is enabled, all other parameters <em>(except for {@link #getFile()})</em> will be ignored.
* The step will return <code>true</code> or <code>false</code> depending on the result
* instead of throwing an exception.
*
* @return if the archive should just be tested or not
*/
public boolean isTest() {
return test;
}

/**
* Test the integrity of the archive instead of extracting it.
* When this parameter is enabled, all other parameters <em>(except for {@link #getFile()})</em> will be ignored.
* The step will return <code>true</code> or <code>false</code> depending on the result
* instead of throwing an exception.
*
* @param test if the archive should just be tested or not
*/
@DataBoundSetter
public void setTest(boolean test) {
this.test = test;
}

/**
* Suppress the verbose output that logs every single file that is dealt with.
*
* @return if verbose logging should be suppressed
*/
public boolean isQuiet() {
return quiet;
}

/**
* Suppress the verbose output that logs every single file that is dealt with.
*
* @param quiet if verbose logging should be suppressed
*/
@DataBoundSetter
public void setQuiet(boolean quiet) {
this.quiet = quiet;
}

}
@@ -1,31 +1,10 @@
package org.jenkinsci.plugins.pipeline.utility.steps;

import org.jenkinsci.plugins.workflow.steps.Step;
import org.kohsuke.stapler.DataBoundSetter;

public abstract class AbstractFileOrTextStep extends Step {
protected String file;
public abstract class AbstractFileOrTextStep extends AbstractFileStep {
protected String text;

/**
* The path to a file in the workspace to read from.
*
* @return the path
*/
public String getFile() {
return file;
}

/**
* The path to a file in the workspace to read from.
*
* @param file the path
*/
@DataBoundSetter
public void setFile(String file) {
this.file = file;
}

/**
* A String containing the formatted data.
*
Expand Down
@@ -0,0 +1,28 @@
package org.jenkinsci.plugins.pipeline.utility.steps;

import org.jenkinsci.plugins.workflow.steps.Step;
import org.kohsuke.stapler.DataBoundSetter;

public abstract class AbstractFileStep extends Step {
private String file;

/**
* The path to a file in the workspace to read from.
*
* @return the path
*/
public String getFile() {
return file;
}

/**
* The path to a file in the workspace to read from.
*
* @param file the path
*/
@DataBoundSetter
public void setFile(String file) {
this.file = file;
}

}

0 comments on commit 492925e

Please sign in to comment.