Store Build Artifacts
To store your build artifacts, you can use file repositories provided by Space Packages. As file repositories use HTTPS, you can upload files with the curl PUT
shell command. Note that you can use public file repositories for distribution of your build artifacts.
Suppose you have an Automation script that generates a build-log/log.txt
file during the build. You want to save the log.txt
artifact to a file repository.
In your project, create a file repository. Suppose the repository URL is
https://files.pkg.jetbrains.space/mycompany/p/my-project/files
Edit the project's
.space.kts
file.To authorize the
curl
tool in the file repository, use theJB_SPACE_CLIENT_TOKEN
environment variable. It is important that the file repository was created in the same project where you run your Automation script. Otherwise, authorization will fail. Learn more about authorization in Space Packages.job("Upload artifact") { // Docker image must contain the curl tool container("alpine/curl") { shellScript { // SOURCE_PATH is path to the build artifact // TARGET_PATH is the destination path in the file repository // Note that each run of the build script creates a separate directory (name = build number) content = """ echo Here go your build activities... echo Uploading artifacts... SOURCE_PATH=build-logs/log.txt TARGET_PATH=logs/${'$'}JB_SPACE_EXECUTION_NUMBER/ REPO_URL=https://files.pkg.jetbrains.space/mycompany/p/my-project/filesrepo curl -i -H "Authorization: Bearer ${'$'}JB_SPACE_CLIENT_TOKEN" -F file=@"${'$'}SOURCE_PATH" ${'$'}REPO_URL/${'$'}TARGET_PATH """ } } }Commit and push the changes. After you run the script, check the file repository. It must contain the uploaded build artifact. For example, if it was the first run of the script (run number is
1
), the path to the file will belogs/1/log.txt
: