An intuitive CLI tool that encompasses the entire cycle of build, package, publish, and deploy operations.
fastci is designed to read the JavaScript pipeline from stdin, and execute in a single process.
cat <<-EOF | fastci
useScript(
'pnpm install',
'pnpm run generate'
)
runScript()
EOFFor functions with long text, fastci supports plain text, plain object, array of lines, base64, and file path.
For example, the useKubeconfig function can be used in the following ways:
useKubeconfig(
"\
apiVersion: v1\n\
kind: aaaa\n\
",
);
useKubeconfig({
content:
"\
apiVersion: v1\n\
kind: aaaa\n\
",
});
useKubeconfig({
content: {
apiVersion: "v1",
kind: "xxx",
},
});
useKubeconfig({
base64: "xxx",
});
useKubeconfig(["apiVersion: v1", "kind: xxx"]);
useKubeconfig("apiVersion: v1", "kind: xxx");Get or set the shell for the current script.
useShell("zsh");
useShell("bash", "-eux");
useShell(["bash", "-eux"]);Get or set the environment variables for the pipeline.
// get all environment variables
useEnv();
// get the value of the specified environment variable
useEnv("key");
// set the value of the specified environment variable
useEnv("key", "value");This function is Long Text Supported
Set the Docker configuration for the pipeline.
// set the Docker config to the specified content
useDockerConfig({
// content can be an object or a string
content: {
auths: {
"registry.cn-hangzhou.aliyuncs.com": {
username: "username",
password: "password",
},
},
},
});
// get the Docker config directory
useDockerConfig();This function is Long Text Supported
Set the Kubernetes configuration for the pipeline.
// set the Kubernetes config to the specified content
useKubeconfig({
// content can be an object or a string
content: {
apiVersion: "v1",
clusters: [],
contexts: [],
users: [],
},
});
// get the Kubernetes config file path
useKubeconfig();This function is Long Text Supported
Get or set the current script for the pipeline.
// script content
useScript(
"\
#!/bin/bash\n\
echo 'Building...'\n\
",
);Execute the current script in the pipeline.
runScript();Get or set the Docker images for docker build and docker push
useDockerImages("my-custom/ubuntu:24.04", "my-custom/ubuntu:24");
useDockerImages(["my-custom/ubuntu:24.04", "my-custom/ubuntu:24"]);
// clear the Docker images
useDockerImages(null);
useDockerImages([]);Get or set the Docker build arguments.
// get all Docker build arguments
useDockerBuildArg();
// get the value of the specified Docker build argument
useDockerBuildArg("key");
// set the value of the specified Docker build argument
useDockerBuildArg("key", "val");This function is Long Text Supported
Get or set the current Dockerfile.
useDockerfile([
"FROM ubuntu:24.04",
'RUN echo "Hello, World!"',
'CMD ["echo", "Hello, World!"]',
]);Get or set the current docker context.
useDockerBuildContext("./docker/");Package the container image with docker build command.
runDockerBuild();Returns the container images as array of string.
Push the container image to the registry.
runDockerPush();Configure the Kubernetes workload for deploying the container image.
useKubernetesWorkload({
// namespace of the workload
namespace: "my-ns",
// kind of the workload
kind: "Deployment",
// name of the workload
name: "my-app",
// if not set, container name will be the same as the workload name
container: "my-app",
// if it's a init container
init: false,
});
// sub-sequence calls will merge the options
// for example, the following two ways are equivalent
useKubernetesWorkload({
namespace: "my-ns",
kind: "Deployment",
});
useKubernetesWorkload({
name: "my-app",
});
//
//
useKubernetesWorkload({
namespace: "my-ns",
kind: "Deployment",
name: "my-app",
});Deploy the container image to the Kubernetes cluster.
deployKubernetesWorkload();Configure the coding.net repository values file for deploying the container image.
useCodingValues({
team: "my-team",
project: "my-project",
repo: "my-repo",
branch: "main",
file: "values.yaml",
update: function (m) {
m[useEnv("JOB_NAME")] = useEnv("BUILD_NUMBER");
},
});
// sub-sequence calls will merge the options
// for example, the following two ways are equivalent
useCodingValues({
team: "my-team",
project: "my-project",
branch: "main",
file: "values.yaml",
update: function (m) {
m[useEnv("JOB_NAME")] = useEnv("BUILD_NUMBER");
},
});
useCodingValues({
repo: "my-repo",
});
//
useCodingValues({
team: "my-team",
project: "my-project",
repo: "my-repo",
branch: "main",
file: "values.yaml",
update: function (m) {
m[useEnv("JOB_NAME")] = useEnv("BUILD_NUMBER");
},
});Deploy the container image to patch coding.net repository values file.
deployCodingValues();fastci will search coding.net credentials from the environment variables, in order:
CODING_MY_TEAM_MY_PROJECT_MY_REPO_USERNAMEandCODING_MY_TEAM_MY_PROJECT_MY_REPO_PASSWORDCODING_MY_TEAM_MY_PROJECT_USERNAMEandCODING_MY_TEAM_MY_PROJECT_PASSWORDCODING_MY_TEAM_USERNAMEandCODING_MY_TEAM_PASSWORDCODING_USERNAMEandCODING_PASSWORD
All characters in the team, project, and repo names will be converted to uppercase.
All non-numeric and non-alphabetic characters in the team, project, and repo names will be replaced with _.
Use the deployer preset and manifest, for compatibility with the legacy toolchain.
useDeployer({
cluster: "eco-staging",
manifest: "mobile/deployer.yml",
profile: "dev",
namespace: "project",
workload: "app",
image: "my-image",
});GUO YANKE, MIT License