#provider #env #ci

ci_env

Detect CI information from the environment

8 releases

0.4.1 Jan 24, 2026
0.4.0 Feb 1, 2025
0.3.0 Apr 11, 2024
0.2.2 Mar 26, 2024
0.1.1 Mar 16, 2023

#315 in Testing

Download history 235/week @ 2025-12-16 64/week @ 2025-12-23 316/week @ 2025-12-30 215/week @ 2026-01-06 372/week @ 2026-01-13 182/week @ 2026-01-20 210/week @ 2026-01-27 61/week @ 2026-02-03 120/week @ 2026-02-10 239/week @ 2026-02-17 145/week @ 2026-02-24 152/week @ 2026-03-03 292/week @ 2026-03-10 218/week @ 2026-03-17 332/week @ 2026-03-24 310/week @ 2026-03-31

1,176 downloads per month

MIT license

42KB
988 lines

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.

Dependencies

~0.2–0.8MB
~19K SLoC