Closed Wei18 closed 9 months ago
import Foundation
// Get the current environment variables
var environment = ProcessInfo.processInfo.environment
print("Current Environment: \(environment)")
// Set a new environment variable
let newEnvironmentValue = "NewValue"
setenv("NEW_VARIABLE", newEnvironmentValue, 1) // The third parameter is used to specify whether to replace an existing variable with the same name
// Retrieve the environment variables again to check if the setting was successful
environment = ProcessInfo.processInfo.environment
print("Updated Environment: \(environment)")
Summary:
Would like to upload artifacts when CI running but test results failed, but
ProcessInfo.processInfo.environment["SNAPSHOT_ARTIFACTS"]
is hardly to control.Detail:
Like
snapshotDirectory
, but artifactDirectory.