I have my build.gradle
setup as follows (listing only plugins for brevity)
plugins {
id 'java'
id 'maven-publish'
id 'signing'
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'com.limark.gitflowsemver' version '0.3.1'
id 'com.google.cloud.tools.jib' version '1.8.0'
}
...
group = 'com.app.my'
// The below line remains commented
// version = '0.1.0'
...
jib {
from {
image = 'azul/zulu-openjdk-alpine:11-jre'
}
to {
image = 'aws_account_id.dkr.ecr.region.amazonaws.com/my-app'
tags = [version]
}
container {
format = 'OCI'
}
}
publishing {
repositories {
maven {
def releasesRepoUrl = "http://localhost:8081/repository/maven-releases/"
def snapshotsRepoUrl = "http://localhost:8081/repository/maven-snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username nexusUsername
password nexusPassword
}
}
}
publications {
mavenJava(MavenPublication) {
artifactId = 'my-app'
from components.java
pom {
name = 'My App'
description = 'My App'
url = 'https://my-app.com'
developers {
developer {
id = 'john'
name = 'John Doe'
email = 'an.emaill@address.here'
}
}
scm {
connection = 'scm:git:ssh://git@bitbucket.org:acme/my-app.git'
developerConnection = 'scm:git:ssh://git@bitbucket.org:acme/my-app.git'
url = 'https://bitbucket.org/acme/my-app'
}
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
The gitflowsemver
plugin updates the project.version
based on the GitFlow branching strategy. The publish
task is able to access the version as updated by the gitflowsemver
plugin, but when I try to build a docker image using jib
, it does not tag the image with the updated version. It is always tagged as unspecified
. But if I un-comment the line version = '0.1.0'
the jib
plugin is able to pick up the version. I am unable to understand why. Any help is highly appreciated.