Jim
Jim

Reputation: 4425

Gitlab artifacts and untracked

What is the use of artifacts:untracked in the artifacts?
I see that untracked files e.g. binaries are part of the artifacts without setting untracked: true.
So what is the use of it?

Upvotes: 8

Views: 15646

Answers (3)

As stated in the documentation:

Use artifacts:untracked to add all Git untracked files as artifacts (along with the paths defined in artifacts:paths).

In other words, by setting this keyword to true every untracked file in the build directory will be uploaded as an artifact, no matter whether they are listed in the artifacts:path section or not.

artifacts:untracked ignores configuration in the repository’s .gitignore, so matching artifacts in .gitignore are included.

It is to said, any file not included in the index will be upload as an artifact if artifacts:untracked is true, even though it is included in .gitignore.

The following has been tested in GitLab 16.11.1 CE:

Given .gitignore:

# More paths here...

### Maven ###
target/

# ... and more paths

Both definitions of the job:

build-job:
  stage: build
  script:
    - mvn clean compile $MVN_OPTS
  artifacts:
    untracked: false # Optional
    paths:
      - "target/"
   

or

```yaml
build-job:
  stage: build
  script:
    - mvn clean compile $MVN_OPTS
  artifacts:
    untracked: true 
   

will finish with the target/ and its contents uploaded as artifacts.

Upvotes: 2

DV82XL
DV82XL

Reputation: 6659

By default, when you define artifacts in a job, any files specified in .gitignore will be ignored and not included in the artifact.

Setting untracked: true will not use .gitignore, i.e. all untracked files will be included. Since untracked: false is the default, adding that won't do anything.

You can find more information at artifacts:untracked.

Upvotes: 7

Adnan
Adnan

Reputation: 2031

artifacts:untracked ignores configuration in the repository’s .gitignore file.

If you use untracked: false, the artifacts won't have any files/folders ignored by .gitignore.

Upvotes: 2

Related Questions