1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use env;
#[derive(Clone, Debug)]
#[cfg_attr(feature = "nightly", non_exhaustive)]
#[allow(missing_docs)]
pub struct Codeship {
pub branch: String,
pub build_number: String,
pub build_url: String,
pub committer_email: String,
pub committer_name: String,
pub committer_username: String,
pub commit_id: String,
pub message: String,
pub repo_name: String,
non_exhaustive: (),
}
impl Codeship {
pub fn from_env() -> Option<Self> {
if !(env("CI")? == "true" && env("CI_NAME")? == "codeship") {
return None;
}
Some(Codeship {
branch: env("CI_BRANCH")?,
build_number: env("CI_BUILD_NUMBER")?,
build_url: env("CI_BUILD_URL")?,
committer_email: env("CI_COMMITTER_EMAIL")?,
committer_name: env("CI_COMMITTER_NAME")?,
committer_username: env("CI_COMMITTER_USERNAME")?,
commit_id: env("CI_COMMIT_ID")?,
message: env("CI_MESSAGE")?,
repo_name: env("CI_REPO_NAME")?,
non_exhaustive: (),
})
}
}