Artifacts not getting collected

artifacts

#1

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:

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.


#2

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:

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

#3

Could you please check if there are any errors logged under the Collect artifacts step?


#4

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, 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.


#5

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:

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.


#6

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?


#7

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

circle.yml:

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:

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.


#8

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

Just need to check if Maven Surefire Plugin is active .


Continuing the discussion from [Artifacts not getting collected]
#9

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…


#10

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


#11