Environment¶
class Environment : YamlExport
Declares which environment this job interacts with.
To declare the environment, see Job.environment.
Types¶
EnvironmentAction¶
EnvironmentTier¶
Functions¶
action¶
fun action(action: Environment.EnvironmentAction)
Specify how this job interacts with the environment. See EnvironmentAction.
Example¶
External resources¶
name¶
Declares the name of the environment, as it will be displayed in the GitLab UI.
val deploy-qa by job {
script {
// …
}
environment {
name("qa")
url("https://qa.your.app/dashboard")
}
}
External resources¶
stopJob¶
Specifies a stopJob that will be executed once the environment should be stopped.
The stop job should have the same configuration but without a declared url.
Example¶
val stopQa by job {
script {
// …
}
environment {
name("qa")
}
}
val deployQa by job {
script {
// …
}
environment {
name("qa")
url("https://qa.your.app/dashboard")
onStop(stopQa)
}
}
External resources¶
tier¶
fun tier(tier: Environment.EnvironmentTier)
toYaml¶
Converts this object into a Yaml object.
url¶
Declares the URL on which the deployed environment is available.
Example¶
val deploy-qa by job {
script {
// …
}
environment {
name("qa")
url("https://qa.your.app/dashboard")
}
}
Example: dynamic URL¶
The URL can be generated by the job itself by combining this feature with Artifacts.dotenv:
val deploy-qa by job {
script {
shell("QA_URL=$(./generate-url) >>qa.env")
}
artifacts {
dotenv("qa.env")
}
environment {
name("qa")
url($$"$QA_URL")
}
}