我的build.gradle
设置如下(为简洁起见仅列出插件)
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
}
该gitflowsemver
插件project.version
基于 GitFlow 分支策略进行更新。该publish
任务能够访问gitflowsemver
插件更新的版本,但是当我尝试使用 构建 docker 映像时jib
,它不会用更新的版本标记映像。它总是被标记为unspecified
。但是,如果我取消注释该行version = '0.1.0'
,jib
插件就可以获取该版本。我无法理解为什么。非常感谢任何帮助。