Dart
Build, run tests, and publish in a Dart project
Currently, Automation does not provide any API for working with Dart. So, the only way to build, test, and publish Dart projects is to use the dart
command-line tool in shell scripts.
The content of .space.kts
might look like follows:
job("Build, run tests, and publish") {
container(displayName = "Run script", image = "dart:stable") {
shellScript {
content = """
echo Build exe...
dart compile exe .\bin\my_dart_project.dart
echo E.g., here you can add a line that puts the exe artifact to a file storage
echo Run tests...
dart test .\test\my_dart_project_test.dart
echo Authorize in Space Packages...
dart pub token add https://dart.pkg.jetbrains.space/mycompany/p/projectkey/mydart --env-var JB_SPACE_CLIENT_TOKEN
echo Start publishing...
dart pub publish -f
"""
}
}
}
Here JB_SPACE_CLIENT_TOKEN
is the environment variable that stores an authorization token. The token lets the Space Automation service to authorize in Space Packages.
Last modified: 15 December 2023