Crates.io | deployment-changelog |
lib.rs | deployment-changelog |
version | 0.1.1 |
source | src |
created_at | 2023-04-09 10:29:06.127936 |
updated_at | 2023-04-09 10:29:06.127936 |
description | A Rust library for generating changelogs based on deployments or commit ranges in Git repositories. It integrates with Bitbucket, Jira, and Spinnaker to retrieve commit, pull request, and issue information for the specified range or Spinnaker environment. The crate provides a structured `Changelog` object with a human-readable display representation. |
homepage | |
repository | https://github.com/Chainso/deployment-changelog |
max_upload_size | |
id | 834076 |
size | 160,711 |
A Rust library for generating changelogs based on deployments or commit ranges in Git repositories. It integrates with Bitbucket, Jira, and Spinnaker to retrieve commit, pull request, and issue information for the specified range or Spinnaker environment. The crate provides a structured Changelog
object with a human-readable display representation.
Add this to your Cargo.toml
:
[dependencies]
deployment_changelog = "0.1.0"
To generate a changelog, you can either use a Git commit range or a Spinnaker environment.
Changelog from a Git commit range
use deployment_changelog::changelog::{Changelog, GitCommitRange};
use deployment_changelog::api::{bitbucket::BitbucketClient, jira::JiraClient};
// Create a BitbucketClient and JiraClient with their respective server URLs.
let bitbucket_client = BitbucketClient::new("https://your-bitbucket-url");
let jira_client = JiraClient::new("https://your-jira-url");
// Define the Git commit range for the changelog.
let commit_range = GitCommitRange {
project: String::from("my-project"),
repo: String::from("my-repo"),
start_commit: String::from("abcdef123456"),
end_commit: String::from("ghijkl789012")
};
// Generate a Changelog using the get_changelog_from_range method and print the formatted output.
let changelog = Changelog::get_changelog_from_range(&bitbucket_client, &jira_client, &commit_range).await.unwrap();
println!("{}", changelog);
Changelog from a Spinnaker environment
use deployment_changelog::changelog::{Changelog, CommitSpecifier, SpinnakerEnvironment};
use deployment_changelog::api::{bitbucket::BitbucketClient, jira::JiraClient, spinnaker::SpinnakerClient};
// Create a BitbucketClient, JiraClient, and SpinnakerClient with their respective server URLs.
let bitbucket_client = BitbucketClient::new("https://your-bitbucket-url");
let jira_client = JiraClient::new("https://your-jira-url");
let spinnaker_client = SpinnakerClient::new("https://your-spinnaker-url");
// Define the Spinnaker environment for the changelog.
let spinnaker_env = SpinnakerEnvironment {
client: spinnaker_client,
app_name: String::from("my-app"),
env: String::from("my-environment")
};
// Create a CommitSpecifier using the Spinnaker environment.
let commit_specifier = CommitSpecifier::Spinnaker(spinnaker_env);
// Generate a Changelog using the get_changelog_from_spinnaker method and print the formatted output.
let changelog = Changelog::new(&bitbucket_client, &jira_client, &commit_specifier).await.unwrap();
println!("{}", changelog);
Before using the deployment_changelog
crate, make sure you have access to the following services:
Additionally, you'll need to generate API tokens or credentials for each service.
To use the deployment_changelog
crate, you need to configure the BitbucketClient
, JiraClient
, and SpinnakerClient
with the necessary API tokens or credentials. Custom TLS certificates and authorization headers can be added to the underlying reqwest
client.
let bitbucket_client = BitbucketClient::new("https://your-bitbucket-url");
let jira_client = JiraClient::new("https://your-jira-url");
let spinnaker_client = SpinnakerClient::new("https://your-spinnaker-url");
For more advanced configuration options, such as custom TLS certificates or custom authorization headers, you can modify the underlying reqwest client used by the BitbucketClient, JiraClient, and SpinnakerClient. Here's an example of how to configure the clients with custom TLS certificates and authorization headers:
use deployment_changelog::api::{
rest::{RestClient, RestClientBuilder},
bitbucket::BitbucketClient,
};
use reqwest::{ClientBuilder, header::{HeaderMap, HeaderValue, AUTHORIZATION}};
let mut headers = HeaderMap::new();
headers.insert(AUTHORIZATION, HeaderValue::from_static("your-custom-authorization-header"));
let mut client_builder = RestClient::builder("https://your-bitbucket-url");
client_builder.client_builder = client_builder.client_builder
.default_headers(headers)
.danger_accept_invalid_certs(true); // Use this option with caution, only in a trusted environment.
let bitbucket_client = BitbucketClient::from_client(client.build()?);
The deployment_changelog
crate also includes a simple command-line interface (CLI) for generating deployment changelogs from public Bitbucket and JIRA instances. To use the CLI, you can clone the repository.
This CLI tool accepts arguments for specifying the Bitbucket and JIRA servers, as well as commit specifier details like Spinnaker environment or Git commit range. You can build and run the CLI tool with cargo run
, providing the required arguments.
Here's an example of how to use the CLI tool:
export BITBUCKET_URL=https://your-bitbucket-url.com/
export JIRA_URL=https://your-jira-url.com/
export SPINNAKER_URL=https://your-spinnaker-url.com/
cargo run --all-features spinnaker important_service prod
export BITBUCKET_URL=https://your-bitbucket-url.com/
export JIRA_URL=https://your-jira-url.com/
cargo run commit-range CATS clowder abc123def4567890a1b2c3d4e5f67890abcdef01 5f56c43386103d10c1cbb415d6f3132da16948a8
The CLI will output the changelog in the console.
The deployment_changelog crate requires Rust 1.53.0 or later.
Find detailed API documentation on docs.rs.
Contributions are welcome! Feel free to open an issue or submit a pull request if you have any ideas or improvements.
This project is licensed under the MIT License.