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
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
+ 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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 "
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.