-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
branch name in the metadata #20
Comments
Could you give an example in which situations this would be helpful? |
IHMO this could be useful when using git-semver for determine the tag of a docker image. |
User story:
So I wrote function, that adds branch name to the Docker/Helm tag. Now artifacts are uniquely and easily identified at all times - if I decide to publish/deploy it, or not.
def call(String appVersion) {
// Docker tags are not compatible with semver (+ sign): https://github.com/distribution/distribution/issues/1201
env.BRANCH_NAME_SANITIZED = env.BRANCH_NAME.replaceAll('[^a-zA-Z0-9_.-]', '-')
println "env.BRANCH_NAME_SANITIZED = $env.BRANCH_NAME_SANITIZED"
env.APPVERSION_SANITIZED = appVersion.replaceAll('[^a-zA-Z0-9_.-]', '-')
println "env.APPVERSION_SANITIZED = $env.APPVERSION_SANITIZED"
Map dockerTags = [:]
if (env.BRANCH_NAME in ['main', 'master'] || git.tagIsSemVer2() ) {
// this logic is later repeated for deployment
dockerTags['versionTag'] = env.APPVERSION_SANITIZED
dockerTags['latestTag'] = 'latest'
} else {
// optionally deployed to optionally deploy code various branches
dockerTags['versionTag'] = "$env.APPVERSION_SANITIZED-$env.BRANCH_NAME_SANITIZED"
dockerTags['latestTag'] = "latest-$env.BRANCH_NAME_SANITIZED"
}
currentBuild.displayName += " 🐳 ${dockerTags['versionTag']}"
println "Tags auto-generated based on branch: $dockerTags"
return dockerTags
} The code above, includes logic, that sometimes ADD branch name, sometimes NOT (if it is main branch). However I see myself removing this abstraction, and make branch name part version at all times, if P.S. If you have troubles imaging in which way of format you should add this "branch" in existing |
Hi
It would be quite useful if there could be a possibility to have a branch name somewhere in the metadata as well.
For not breaking back compatibility, it could be implemented as a placeholder for a custom format (for example x.y.z+b-m)
The text was updated successfully, but these errors were encountered: