Archiving Java Artifacts
In a follow-up to yesterday’s post, sometimes you don’t want to build a Docker image directly from your Java code.
With this simple change, I can archive the built resources to “somewhere”.
image: maven:3-openjdk-11
build-jar:
rules:
- if: vars.CI_COMMIT_BRANCH != 'master'
when: never
script:
- mvn clean package
artifacts:
paths:
- ./build/target/ci-demo-0.0.1-SNAPSHOT.jar
This will schedule a call to an archiver process after the build-jar
task completes.
In the default deployment configuration, this delegates to a “mock-archiver” that actually does nothing more than echo the names of the files to to be archived.
But, you can configure this easily, and your container will be executed in the correct workspace, with the names of the files to be archived.
The default archiver log output will look like this in the pipelinerun logs:
[build-jar-archiver : build-jar-archiver-archiver] 2020/04/30 22:12:30 uploading ./build/target/ci-demo-0.0.1-SNAPSHOT.jar to https://example.com/testing