M Jenkinsfile => Jenkinsfile +2 -2
@@ 20,8 20,8 @@ pipeline {
stage('Docker') {
steps {
sh 'docker login registry.gitlab.com -u ${DOCKER_LOGIN_CREDS_USR} -p ${DOCKER_LOGIN_CREDS_PSW}'
- sh './spacetime build_docker_api'
- sh './spacetime build_docker_server'
+ sh 'STK_CHANNEL=bleeding STK_BUILD_NUM=${BUILD_NUMBER} ./spacetime build_docker_api'
+ sh 'STK_CHANNEL=bleeding STK_BUILD_NUM=${BUILD_NUMBER} ./spacetime build_docker_server'
}
}
}
M server/build.rs => server/build.rs +6 -0
@@ 1,3 1,4 @@
+use std::process::Command;
use cargo_metadata::MetadataCommand;
fn main() {
@@ 15,8 16,13 @@ fn main() {
let version_name = root.metadata["version-name"].to_string().replace('"', "");
let description = root.metadata["slp-description"].to_string().replace('"', "");
+ let output = Command::new("git").args(["rev-parse", "--short", "HEAD"]).output().unwrap();
+ let git_hash = String::from_utf8(output.stdout).unwrap();
+
println!("cargo:rustc-env=STK_VERSION={}", version);
println!("cargo:rustc-env=STK_VERSION_NAME={}", version_name);
println!("cargo:rustc-env=STK_SLP_DESCRIPTION={}", description);
+ println!("cargo:rustc-env=STK_CHANNEL={}", std::env::var("STK_CHANNEL").unwrap_or("dev".to_string()));
+ println!("cargo:rustc-env=STK_BUILD={}-{}-{}", std::env::var("STK_CHANNEL").unwrap_or("dev".to_string()), std::env::var("STK_BUILD_NUM").unwrap_or("local".to_string()), git_hash);
println!("cargo:rerun-if-changed=Cargo.toml");
}=
\ No newline at end of file
M server/src/main.rs => server/src/main.rs +7 -1
@@ 58,6 58,8 @@ async fn _handle_request(mut conn: TcpStream, remote_addr: SocketAddr, mgr: Clie
name: env!("STK_VERSION_NAME").to_string(), // Set by build.rs
number: env!("STK_VERSION").to_string(), // Set by build.rs
protocol: PROTOCOL_VERSION,
+ channel: env!("STK_CHANNEL").to_string(),
+ build: env!("STK_BUILD").to_string()
},
players: CMGR.usernames.read().await.len() as u32,
description: env!("STK_SLP_DESCRIPTION").to_string(),
@@ 162,6 164,8 @@ lazy_static! {
async fn main() {
simple_logger::init_with_level(Level::Debug).expect("Unable to start logging service");
+ info!("StarKingdoms server (v: {}, build {})", env!("STK_VERSION"), env!("STK_BUILD"));
+
if std::env::var("STK_API_KEY").is_err() {
error!("Unable to read the API key from STK_API_KEY. Ensure it is set, and has a valid value.");
std::process::exit(1);
@@ 209,5 213,7 @@ pub struct ServerPingResponse {
pub struct ServerPingResponseVersion {
pub name: String,
pub number: String,
- pub protocol: u32
+ pub protocol: u32,
+ pub channel: String,
+ pub build: String
}