Plugin Development Guide
Language: TypeScript is recommended for plugin code.
Writing Core Code
The core logic of the plugin can be written in JavaScript/TypeScript. If you need to use scripts in other languages, please call and execute them through JavaScript/TypeScript.
Development suggestions: First implement the most core functions to ensure that the plugin can run basically, then gradually iterate and add more features.
Example: Developing a Plugin with Node.js
import core from '@actions/core';
try {
const myInput = core.getInput('myInput'); // Get plugin input
const ref = process.env['ATOMGIT_REF']; // Get system variables
const result = `Hello ${pipelineId}, ${myInput}!`; // Plugin core logic
} catch (error) {
core.setFailed(`Action failed with error: ${error.message}`);
}
Parameter acquisition methods:
| Method | Purpose |
|---|---|
process.env[] | Get environment variable parameters |
core.getInput() | Get plugin input parameters |
Recommended Toolkits
GitHub Actions Toolkit is a recommended third-party toolkit used during development, providing modules such as @actions/core, @actions/io, @actions/exec, @actions/glob, and @actions/http-client, which can assist in plugin code development.
Log Output
Use the @actions/core library to output logs:
const core = require('@actions/core');
core.info('Starting action...');
core.warning('This is a warning message');
core.error('This is an error message');
| Method | Purpose |
|---|---|
core.info() | General log information |
core.warning() | Warning information |
core.error() | Error information |
Execution Status Feedback
- Normal execution completion: The task process returns
0 - An exception or error occurs: Modify the process return via
core.setFailed(). If the scheduling framework captures a non-zero return, it determines that the task has failed.
Result Output and Collection
The plugin task defines the output collection file path during runtime through the system variable $ATOMGIT_OUTPUT. The content output to this file will be collected by the system into the pipeline step, job, and pipeline level output results.
Method One: Real-time Output via Log Keywords
This method collects and displays the output in real time on the pipeline. If the same key exists, it will be overwritten; if different keys exist, they will be appended.
log.info(`::set-output var=${outputkey}:${outputvalue}`)