Is there some way intended to store non-sensitive data in Jenkins scoped to a build configuration so it can be read from a pipeline script?
We're migrating to a new Octopus Deploy server, and our Jenkinsfile looks like this:
pipeline {
environment {
OCTOPUS_CLI_SERVER = "https://octopus.example.com"
OCTOPUS_CLI_API_KEY = credentials("Octopus_Deploy_ApiKey")
}
// ...
}
I can update the API key centrally via the Jenkins credential manager, but I'll have to edit and commit the change to OCTOPUS_CLI_SERVER
in every branch, since the URL is hard-coded. As long as I'm changing this, I'm wondering if there's a better way than just hard-coding a new value.
I could store the Octopus server URL in the credential manager and access it the same way, but then its value will be redacted from logs, and that could be annoying. Ideally, what I'm looking for could have a different value for multiple projects. For example, both Project A and Project B might read a variable named "PUBLIC_DOMAIN", but one would get "a.example.com" and the other would get "b.example.com".
I'm mentioning Octopus Deploy because it happens to be the change we're making, but this question could apply to any data accessed from a Jenkins pipeline, this isn't specific to Octopus Deploy.
There are a nearly unlimited ways to do this. Here are three that come to mind:
You could use a Jenkins Pipeline shared library to store configuration values in a central location.
You could store the value in a remote file or repository and have your pipeline read in the value from the the remote file or a file in the repository.
You could have the pipeline fetch the value from another server via HTTP REST API.