ci_env

Crates.ioci_env
lib.rsci_env
version0.3.0
sourcesrc
created_at2023-03-16 20:49:48.3124
updated_at2024-04-11 00:00:58.811992
descriptionDetect CI information from the environment.
homepagehttps://github.com/milesj/rust-cicd-env
repositoryhttps://github.com/milesj/rust-cicd-env
max_upload_size
id812066
size39,562
Miles Johnson (milesj)

documentation

README

ci_env

Crates.io Crates.io

Detects CI (continuous integration) information from the current environment.

Usage

To start, detect if in a CI environment.

ci_env::is_ci();

Or detect which CI provider is being used.

ci_env::detect_provider(); // GithubActions

And most importantly, extract information about the CI environment and CI provider. This includes branch, commit, and pull request information.

use ci_env::get_environment;

if let Some(ci) = get_environment() {
	println!("Provider: {:?}", ci.provider);
	println!("Branch: {}", ci.branch);
	println!("Commit: {}", ci.revision);

	if let Some(pr_number) = ci.request_id {
		println!("PR #: {}", pr_number);
	}
}

This library will properly take into account source and target branches when a pull request is involved. Do note though that not all providers provide this information.

Commit count: 37

cargo fmt