Skip to main content

nerdbank_gitversioning/cloud_build_services/
atlassian_bamboo.rs

1// Copyright (c) .NET Foundation and Contributors. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4//! [Atlassian Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html) support.
5
6use std::io::{self, Write};
7
8use crate::cloud::{
9    CloudBuild, EnvironmentVariables, empty_variables, env, is_nonempty, should_start_with,
10};
11
12/// Atlassian Bamboo cloud-build integration.
13pub struct AtlassianBamboo;
14
15impl CloudBuild for AtlassianBamboo {
16    fn name(&self) -> &'static str {
17        "AtlassianBamboo"
18    }
19
20    fn is_applicable(&self) -> bool {
21        is_nonempty(env("bamboo.buildKey").as_deref())
22    }
23
24    fn is_pull_request(&self) -> bool {
25        false
26    }
27
28    fn building_branch(&self) -> Option<String> {
29        should_start_with(env("bamboo.planRepository.branch"), "refs/heads/")
30    }
31
32    fn building_tag(&self) -> Option<String> {
33        None
34    }
35
36    fn git_commit_id(&self) -> Option<String> {
37        env("bamboo.planRepository.revision")
38    }
39
40    fn set_cloud_build_number(
41        &self,
42        _build_number: &str,
43        _stdout: &mut dyn Write,
44        _stderr: &mut dyn Write,
45    ) -> io::Result<EnvironmentVariables> {
46        Ok(empty_variables())
47    }
48
49    fn set_cloud_build_variable(
50        &self,
51        _name: &str,
52        _value: &str,
53        _stdout: &mut dyn Write,
54        _stderr: &mut dyn Write,
55    ) -> io::Result<EnvironmentVariables> {
56        Ok(empty_variables())
57    }
58}