I have a pipeline to build a Docker image in every push to specific branches in my git repository. The problem is that semantic versioning is using '+' character to specifying the metadata section in the version name. I need to replace this char for another supported by Docker in the image name. There is any way to replace that character or use a custom version name?
I am using nebula.release to inferring the project version.
id 'nebula.release' version '10.1.1'
jib {
to {
image = "registry.gitlab.com.uy:5005/project/app:$version"
auth {
username = System.getenv('CI_REGISTRY_USER')
password = System.getenv('CI_REGISTRY_PASSWORD')
}
tags = ['latest']
}
container {
ports = ['8080']
environment = [
SPRING_OUTPUT_ANSI_ENABLED: 'ALWAYS',
]
useCurrentTimestamp = true
}
allowInsecureRegistries = true
}
jibDockerBuild.dependsOn bootJar
This is the error:
- What went wrong: Execution failed for task ':jib'.
com.google.cloud.tools.jib.image.InvalidImageReferenceException: Invalid image reference: registry.gitlab.com.uy:5005/project/app:1.0.0-rc.1.dev.0+108db18
I created this task in my build.gradle file, Is there any way to reuse it?
task cleanVersion {
ext.sanitizeVersion = { version ->
return version.toString().replace('+', '_')
}
doLast {
println sanitizeVersion("$version")
}
}
I could use some help. Thanks in advance for your time.
Since build scripts are code and it looks like jib
is an extension, project.version
is a retrieval property (compared to a task output or something generated), you can use the same code you have in your current cleanVersion
task to configure the extension.
image = "registry.gitlab.com.uy:5005/project/app:${version.toString().replace('+', '_')}"