jfrog-cli icon indicating copy to clipboard operation
jfrog-cli copied to clipboard

Cannot exclude files during terraform module publish

Open cdivitotawela opened this issue 1 year ago • 2 comments

Describe the bug

Using following command to publish a terraform module and want to exclude .git and .github directories. Published module zip file contains the excluded directories. jf terraform publish --namespace mynamespace --provider azurerm --tag 'v0.0.8' --exclusions "\*.git\*"

Tried different options --exclusions '.git;.github' and none seems to be working.

I can see DEBUG logs indicate it ignored .git directory but it is still included.

09:30:50 [Debug] Sending HTTP GET request to: https://mynamespace.jfrog.io/artifactory/api/system/version
09:30:50 [Debug] The path '/Users/***/github/***/***/.DS_Store' is excluded
09:30:50 [Debug] The path '/Users/***/github/***/***/.git' is excluded

Following instruction in https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration#terraform-publish example 2

Current behavior

Cannot exclude files using --exclusions when publishing terraform module

Reproduction steps

  1. Create a simple terraform module in a git repository and run following command to exclude the .git folder jf terraform publish --namespace mynamespace --provider azurerm --tag 'v0.0.8' --exclusions "\*.git\*"
  2. Check the zip file content in Artifactory portal and .git folder is included in the zip file

Expected behavior

Any file, directory added in --exclusions argument must be excluded from the zip file uploaded to Artifactory

JFrog CLI version

jf version 2.56.0

Operating system type and version

OSX

JFrog Artifactory version

Cloud

JFrog Xray version

No response

cdivitotawela avatar Jul 04 '24 23:07 cdivitotawela

Having the same issue. Trying to eclude .git, .github, .terraform. The only thing that works is using , which, in our use case, excludes things we intend to keep in a couple of cases

loshea-bmcd avatar Aug 01 '24 15:08 loshea-bmcd

Same issue here - my intended workaround is to use rsync to copy the directory to somewhere else but excluding the files I don't want, and then using jf to upload the temporary directory which has already been sanitised. But this is a frustrating bug, especially since the documentation states explicitly that this is possible in the last paragraph.

gchappel avatar Sep 09 '24 09:09 gchappel

Hey @cdivitotawela,

I attempted to reproduce the issue using JFrog CLI version 2.56.0 as well as the latest version (2.73.3), and the --exclusions flag appears to be working as expected for me.

Steps Taken:

  • Environment Setup: Created a directory structure with .git and .github folders. Added placeholder files inside these directories.
  • Commands Used: jf terraform-config to configure the Terraform project. JFROG_CLI_LOG_LEVEL=DEBUG jf terraform publish --namespace=mynamespace --provider=azurerm --tag='v0.0.8' --exclusions='*.git*;*.github*' to publish the module while excluding certain directories. Results: Published an artifact named v0.0.8.zip. Examined the contents of the ZIP file and confirmed that the excluded directories (i.e., .git and .github) were not present.

Directory Structure Created: Image

Contents of the ZIP File: Image

Observations and Insights: I noticed that using --exclusions='\*.git\*' with backslashes did not work, whereas --exclusions='*.git*' without backslashes worked correctly. According to the JFrog CLI documentation, a list of semicolon-separated exclude patterns is supported, which allows using wildcards.

Documentation Reference: You can exclude files and directories from being scanned by the commands using the --exclusions option. For example:

jf terraform publish --namespace=example --provider=aws --tag=v0.0.2 --exclusions="*test*;*ignore*"

Request for Clarification:

  • Could you please let me know if this issue still persists on your end?
  • Are there any specific steps or configurations I might be missing that could be contributing to the discrepancy?

Thanks!

agrasth avatar Feb 25 '25 09:02 agrasth

Closing this issue. Feel free to reopen if the issue still persists.

agrasth avatar Mar 05 '25 05:03 agrasth