Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

- Add `--install-group` parameter to `sentry-cli build upload` for controlling update visibility between builds ([#3094](https://github.com/getsentry/sentry-cli/pull/3094))

## 3.1.0

### New Features
Expand Down
6 changes: 6 additions & 0 deletions src/api/data_types/chunking/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use sha1_smol::Digest;

use super::ChunkedFileState;

fn is_empty_slice<T>(slice: &[T]) -> bool {
slice.is_empty()
}

#[derive(Debug, Serialize)]
pub struct ChunkedBuildRequest<'a> {
pub checksum: Digest,
Expand All @@ -13,6 +17,8 @@ pub struct ChunkedBuildRequest<'a> {
pub build_configuration: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
pub release_notes: Option<&'a str>,
#[serde(skip_serializing_if = "is_empty_slice")]
pub install_groups: &'a [String],
#[serde(flatten)]
pub vcs_info: &'a VcsInfo<'a>,
}
Expand Down
51 changes: 36 additions & 15 deletions src/commands/build/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ pub fn make_command(command: Command) -> Command {
.long("release-notes")
.help("The release notes to use for the upload.")
)
.arg(
Arg::new("install_group")
.long("install-group")
.action(ArgAction::Append)
.help(
"The install group(s) for this build. Can be specified multiple times. \
Builds with at least one matching install group will be shown updates \
for each other.",
)
)
.arg(
Arg::new("force_git_metadata")
.long("force-git-metadata")
Expand Down Expand Up @@ -175,6 +185,10 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

let build_configuration = matches.get_one("build_configuration").map(String::as_str);
let release_notes = matches.get_one("release_notes").map(String::as_str);
let install_groups: Vec<String> = matches
.get_many::<String>("install_group")
.map(|vals| vals.cloned().collect())
.unwrap_or_default();

let (plugin_name, plugin_version) = parse_plugin_from_pipeline(config.get_pipeline_env());

Expand Down Expand Up @@ -237,15 +251,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
for (path, zip) in normalized_zips {
info!("Uploading file: {}", path.display());
let bytes = ByteView::open(zip.path())?;
match upload_file(
&authenticated_api,
&bytes,
&org,
&project,
let metadata = BuildMetadata {
build_configuration,
release_notes,
&vcs_info,
) {
install_groups: &install_groups,
vcs_info: &vcs_info,
};
match upload_file(&authenticated_api, &bytes, &org, &project, &metadata) {
Ok(artifact_url) => {
info!("Successfully uploaded file: {}", path.display());
uploaded_paths_and_urls.push((path.to_path_buf(), artifact_url));
Expand Down Expand Up @@ -588,19 +600,27 @@ fn handle_directory(
normalize_directory(path, temp_dir.path(), plugin_name, plugin_version)
}

/// Metadata for a build upload.
struct BuildMetadata<'a> {
build_configuration: Option<&'a str>,
release_notes: Option<&'a str>,
install_groups: &'a [String],
vcs_info: &'a VcsInfo<'a>,
}

/// Returns artifact url if upload was successful.
fn upload_file(
api: &AuthenticatedApi,
bytes: &[u8],
org: &str,
project: &str,
build_configuration: Option<&str>,
release_notes: Option<&str>,
vcs_info: &VcsInfo<'_>,
metadata: &BuildMetadata<'_>,
) -> Result<String> {
debug!(
"Uploading file to organization: {org}, project: {project}, build_configuration: {}, vcs_info: {vcs_info:?}",
build_configuration.unwrap_or("unknown"),
"Uploading file to organization: {org}, project: {project}, build_configuration: {}, install_groups: {:?}, vcs_info: {:?}",
metadata.build_configuration.unwrap_or("unknown"),
metadata.install_groups,
metadata.vcs_info,
);

let chunk_upload_options = api.get_chunk_upload_options(org)?;
Expand Down Expand Up @@ -641,9 +661,10 @@ fn upload_file(
&ChunkedBuildRequest {
checksum,
chunks: &checksums,
build_configuration,
release_notes,
vcs_info,
build_configuration: metadata.build_configuration,
release_notes: metadata.release_notes,
install_groups: metadata.install_groups,
vcs_info: metadata.vcs_info,
},
)?;
chunks.retain(|Chunk((digest, _))| response.missing_chunks.contains(digest));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ Options:
--release-notes <release_notes>
The release notes to use for the upload.

--install-group <install_group>
The install group(s) for this build. Can be specified multiple times. Builds with at
least one matching install group will be shown updates for each other.

--force-git-metadata
Force collection and sending of git metadata (branch, commit, etc.). If neither this nor
--no-git-metadata is specified, git metadata is automatically collected when running in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Options:
--release-notes <release_notes>
The release notes to use for the upload.

--install-group <install_group>
The install group(s) for this build. Can be specified multiple times. Builds with at
least one matching install group will be shown updates for each other.

--force-git-metadata
Force collection and sending of git metadata (branch, commit, etc.). If neither this nor
--no-git-metadata is specified, git metadata is automatically collected when running in
Expand Down
Loading