Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Skip a file during creation of zip

Robin April 4, 2023

I want to skip a file named .gitignore during creation of the zip i tried -x and --exclude command but it is not working here is my code .

pipelines:
  branches:
    main:
      - step:
          name: Copy code as ZIP file
          script:
            - apt-get update && apt-get install -y zip
            - git archive --format=zip HEAD -o code.zip -x .gitignore
          artifacts:
            - code.zip

I searched on forum but cannot find any solution  

1 answer

1 accepted

0 votes
Answer accepted
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2023

G'day @Robin 

Based on your YML parameter, you can't use -x on the git archive. Instead, try the following example to exclude .gitignore

pipelines:
  branches:
    main:
      - step:
          name: Copy code as ZIP file
          script:
            - apt-get update && apt-get install -y zip
            - git archive --format=zip HEAD -o code.zip ":(exclude).gitignore"
          artifacts:
            - code.zip 

Use ":(exclude).gitignore" to skip .gitignore when it's archiving.

I hope this helps.

Cheers,
Syahrul

Robin April 5, 2023

+ git archive --format=zip HEAD -o code.zip ":(exclude).gitignore/"
fatal: There is nothing to exclude from by :(exclude) patterns.

Perhaps you forgot to add either ':/' or '.' ?

 

Not working for me this is from logs.

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2023

Hey @Robin 

Interesting, this works as expected on my end. As you can see on the screenshot below, it skipped the .gitignore when creating the zip file:

Screenshot 2023-04-06 at 3.21.18 PM.png

May I know what image are you using? I've read that older git may have issues using (exclude) parameters. I'm using the default image "

atlassian/default-image:3".
Could you try changing the image and see if that works?
Cheers,
Syahrul
Robin April 5, 2023

Thank u so much after changing image it worked .

Like Syahrul likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events