# Artifacts not getting collected

**URL:** <https://discuss.circleci.com/t/artifacts-not-getting-collected/465>\
**Category:** Bug Reports\
**Tags:** artifacts\
**Created:** [November 11, 2015, 5:44pm UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465 "2015-11-11T17:44:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![RAnders00](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/randers00/32/322_2.png) [@RAnders00](https://discuss.circleci.com/u/RAnders00)\
**Post date:** [November 11, 2015, 5:44pm UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/1 "2015-11-11T17:44:45Z")

</div>

I hive the following problem:

Suddenly, the built artifacts of my project are not published properly in the artifacts tab. From one commit to the next, they stopped being collected - only my JUnit test result XML files are getting collected (from the `$CIRCLE_TEST_RESULTS` directory)

This is what I tried:

- I SSHed into my build and verified the files are there.
- I copied all files from the directories they were in into the `$CIRCLE_ARTIFACTS` directory.
- I specified the artifact paths in the circle.yml as
  - Relative to the build directory (`/build/libs/*.jar`)
  - Relative to the home (`~/Kayon/build/libs/*.jar`, where `Kayon` is the name of the project)
  - Absolute (`/home/user/ubuntu/Kayon/build/libs/*.jar`)

- Turning off parallelism down to 1x

This is a minimal `circle.yml` file representing my setup:

```auto
general:
  artifacts:
    - "build/libs/*.jar"

```

All of the above does not cause the jar files in the specified directory being collected. The “collecting artifacts” step just won’t go over them, as if they do not exist.

This issue came out of nowhere - the build when it stopped working properly did not change anything significant on the `circle.yml` - I even tried reverting the circle.yml to what it looked like before the commit where it started.

---

<div class="post-metadata">

**Author:** ![yatesco](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yatesco/32/8976_2.png) [@yatesco](https://discuss.circleci.com/u/yatesco)\
**Post date:** [November 11, 2015, 6:09pm UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/2 "2015-11-11T18:09:18Z")

</div>

I can also report that build artefacts are no longer collected (they used to be up until a few days ago) with the following config:

```auto
general:
  artifacts:
    - "target/*.war"

```

---

<div class="post-metadata">

**Author:** ![alexey](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/alexey/32/42_2.png) [@alexey](https://discuss.circleci.com/u/alexey)\
**Post date:** [November 11, 2015, 7:45pm UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/3 "2015-11-11T19:45:37Z")

</div>

Could you please check if there are any errors logged under the _Collect artifacts_ step?

---

<div class="post-metadata">

**Author:** ![RAnders00](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/randers00/32/322_2.png) [@RAnders00](https://discuss.circleci.com/u/RAnders00)\
**Post date:** [November 11, 2015, 8:04pm UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/4 "2015-11-11T20:04:50Z")

</div>

It does not look like there are any issues when transferring the files to Amazon Web Services. The process starts off wanting to collect 14 artifacts (from the test result directory) - and it finished having collected those correctly. The gist below is a sample of what I am getting.

```
https://gist.github.com/RAnders00/b087a5ea1c442931b3c2

```

_(Sorry - apparently the link counting feature counts in the parsed markdown - which generates 3 links (one to [gist.github.com](http://gist.github.com), the title is linked and “show untruncated file” at the bottom) in one embedded gist “widget” and I can only post up to 2 links - just copy it into your browser address bar)_

Imagine you had not setup the `circle.yml` file to collect artifacts at all, that’s how it is behaving. You never see any notice about something failing, never do you see your directories specified mentioned anywhere. Not that that’s an issue, normally they would not get logged as well, but there are no (additionally to normal) traces to find in the logs is what I wanted to say.

---

<div class="post-metadata">

**Author:** ![RAnders00](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/randers00/32/322_2.png) [@RAnders00](https://discuss.circleci.com/u/RAnders00)\
**Post date:** [November 11, 2015, 9:10pm UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/5 "2015-11-11T21:10:40Z")

</div>

So apparently, I was doing the copying wrongly. I am now using gradle to copy the artifacts to `$CIRCLE_ARTIFACTS` and they are getting collected like expected. **It just won’t collect from the directories specified in `circle.yml`.** This is the gradle task I am using:

```auto
task copyCIArtifacts << { // because why not, doubleshift and nested copy (intuitive, isn't it?)
    copy {
        from(file('build/libs/').listFiles() + file('build/distributions/').listFiles())
        into System.getenv('CIRCLE_ARTIFACTS')
    }
}

```

Somebody decent at bash could probably come up with something better than this, but I am only good in JVM languages generally, that’s why I did it with gradle.

---

<div class="post-metadata">

**Author:** ![yatesco](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yatesco/32/8976_2.png) [@yatesco](https://discuss.circleci.com/u/yatesco)\
**Post date:** [November 13, 2015, 12:18am UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/6 "2015-11-13T00:18:20Z")

</div>

Where did you call this task? I looked at the sample circle.yml for an ‘after the build’ hook but couldn’t find one… Would you mind sharing your circle.yml?

---

<div class="post-metadata">

**Author:** ![RAnders00](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/randers00/32/322_2.png) [@RAnders00](https://discuss.circleci.com/u/RAnders00)\
**Post date:** [November 13, 2015, 7:29am UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/7 "2015-11-13T07:29:25Z")

</div>

I fixed the artifact issue in a separate branch, `artifact-fix`.

Here is the latest build, where I call the gradle task:

[RAnders00\Kayon `artifact-fix` #41](https://circleci.com/gh/RAnders00/Kayon/41)

`circle.yml`:

```auto
machine:
  java:
    version: oraclejdk8
general:
  artifacts:
    - "build/libs/*.jar"
    - "build/distributions/*.zip"
test:
  post:
    - mkdir -p $CIRCLE_TEST_REPORTS/junit/
    - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
    - ./gradlew jar javadocJar sourcesJar shadowJar distZip copyCIArtifacts

```

`build.gradle`:

```auto
task copyCIArtifacts << { // because why not, doubleshift and nested copy (intuitive, isn't it?)
    if (System.getenv("CIRCLECI").equals("true")) {
        copy {
            from(file('build/libs/').listFiles() + file('build/distributions/').listFiles())
            into System.getenv('CIRCLE_ARTIFACTS')
        }
    }
}

```

Basically, gradle is a build system for the Java Virtual Machine (Java, Groovy, Scala, Kotlin, etc…). I just added a new task to the set of existing ones (like `compileJava`, `classes`, `jar`, `test`, etc…) that does this utility, since I am mostly experienced in Java-like languages. The job this accomplishes could also easily done with bash. It just copies my artifacts to the `$CIRCLE_ARTIFACTS` directory.

I am using gradle 2.8.

---

<div class="post-metadata">

**Author:** ![DevendraMeena1](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/devendrameena1/32/302_2.png) [@DevendraMeena1](https://discuss.circleci.com/u/DevendraMeena1)\
**Post date:** [November 13, 2015, 10:12am UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/8 "2015-11-13T10:12:09Z")

</div>

Is it possible for you to share the content of .xml file ?

Just need to check if Maven Surefire Plugin is active .

---

<div class="post-metadata">

**Author:** ![yatesco](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yatesco/32/8976_2.png) [@yatesco](https://discuss.circleci.com/u/yatesco)\
**Post date:** [November 13, 2015, 10:53am UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/9 "2015-11-13T10:53:14Z")

</div>

This is great - thanks. Just to confirm - does tests:posts run _after_ the build or just after the _tests_? My pipeline (using ‘lein’ for Clojure):

- download the dependencies
- build
- run tests
- build distributable WAR
- \*\*\* here is where I need to copy the target/\*.war \*\*\*

I can change the pipeline so it builds the WAR before the tests if needed I guess…

---

<div class="post-metadata">

**Author:** ![yatesco](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yatesco/32/8976_2.png) [@yatesco](https://discuss.circleci.com/u/yatesco)\
**Post date:** [November 13, 2015, 12:07pm UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/10 "2015-11-13T12:07:19Z")

</div>

I can confirm, for others like me, that the `test` phase is the actual `build` phase and this approach does work.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:33am UTC](https://discuss.circleci.com/t/artifacts-not-getting-collected/465/11 "2018-06-18T11:33:53Z")

</div>


