Command lineAutomation
Agents and tools from a file
An agent has more settings than options can comfortably carry, so a JSON file describes it. Keep the file in a repository, review it like code and create the agent from it in another project or on another platform.
Step 1: Write an agent to a file
With --as-file the command prints exactly what kcloud agents create --file takes. Redirect it to a file, as in > release-notes.json.
$ kcloud agents show sandbox/nightly --as-fileOutput
{
"name": "Nightly",
"slug": "nightly",
"description": "",
"kikimoraVersion": "0.12.0",
"nodeId": "0195a3c4-7e21-7b6d-9f40-3c81a4d2e600",
"requiredCapabilities": [],
"gitCredentialIds": [
"0195a3c4-7e21-7b6d-9f40-3c81a4d2e601"
],
"repositories": [
{
"repositoryId": "0195a3c4-7e21-7b6d-9f40-3c81a4d2e602",
"directory": "kikimora"
}
],
"toolAssignments": [
{
"toolId": "0195a3c4-7e21-7b6d-9f40-3c81a4d2e603",
"scope": "both"
}
],
"prompts": {
"monitor": "Read the open issues every hour and queue the ones that are ready to work on.",
"executor": "Work on one issue per session and open a pull request with the change."
},
"settings": {},
"timezone": "Europe/Warsaw",
"machine": {
"docker": false,
"browser": false,
"diskGb": 20
}
}
The file names the node, the tokens of the repository providers (gitCredentialIds), the repositories and the tools by ids, which differ between organizations and platforms. --node of kcloud agents create replaces the nodeId of the file, and --require the list requiredCapabilities. In the example release-notes.json is the file of the agent Nightly with its name, slug, description and prompts changed.
Step 2: Create an agent from a file
The command creates the agent the file describes and says how to start it. In place of a path, - reads the file from stdin.
$ kcloud agents create --project sandbox --file release-notes.jsonOutput
Created Release notes (release-notes) as 0195a3c4-7e21-7b6d-9f40-3c81a4d2e600; kcloud agents start sandbox/release-notes starts it.
Step 3: Change an agent from a file
The file of a change holds the sections to change alone, under sections, such as general, version, repositories, tools, prompts, settings, timezone or machine. Here change.json is {"sections": {"prompts": {"monitor": "...", "executor": "..."}}}. When the change needs a new container, the command names the command that applies it.
$ kcloud agents set sandbox/release-notes --file - < change.jsonOutput
Changed Release notes.
Without --file and with a terminal, kcloud agents create asks for the settings step by step. With --yes it asks nothing and refuses what is missing, which suits a script.
Tools come from a file too: kcloud tools create --project sandbox --file build-settings.json and kcloud tools update build-settings --project sandbox --file change.json. The Tools page describes the format of the file and shows examples with their output.
Matches the panel at cloud.kikimora.dev.