[FIXED JENKINS-18272]
Expose various key properties of POM as environment variables.
- Loading branch information
@@ -183,7 +183,18 @@ public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedE | ||
mvn.buildEnvVars(envs); | ||
} | ||
} | ||
|
||
|
||
MavenModule root = getProject().getRootModule(); | ||
if (root!=null) {// I don't think it can ever be null but let's be defensive | ||
// TODO: this needs to be documented but where? | ||
This comment has been minimized.
This comment has been minimized.
imod
Member
|
||
envs.put("POM_DISPLAYNAME", root.getDisplayName()); | ||
envs.put("POM_VERSION", root.getVersion()); | ||
envs.put("POM_GROUPID", root.getGroupId()); | ||
envs.put("POM_ARTIFACTID", root.getArtifactId()); | ||
envs.put("POM_PACKAGING", root.getPackaging()); | ||
This comment has been minimized.
This comment has been minimized. |
||
envs.put("POM_RELATIVEPATH", root.getRelativePath()); | ||
} | ||
|
||
return envs; | ||
} | ||
|
||
8 comments
on commit 59afb8b
This comment has been minimized.
This comment has been minimized.
So what about multi-module builds? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I understand @kutzi 's reasoning, but (1) for compatibility it's easier not to rename them and (2) I'm not sure how to name environment variables if we are to expose them from other modules, so I'm inclined to just stick to this and not worry about multi-module builds. At some point I feel like this is Maven's job to provide tooling to extract these information. |
This comment has been minimized.
This comment has been minimized.
getEnvironment() is called before the code checkout and parsing of the POMs if I am not mistaken. As such this will just return the info for the previous which will could cause unexpected confusion of users esp so when using a release plugin. |
This comment has been minimized.
This comment has been minimized.
When choose "Perform Maven Release" , how can I get "Release Version" and "Development version" ? "POM_VERSION" is not I wanted. |
This comment has been minimized.
This comment has been minimized.
Hi,
I will try to find a trick with other environment variables for my current project, but I hope this idea could help others in a later time |
This comment has been minimized.
This comment has been minimized.
Is there a way to access developerConnection? Or perhaps to make all of the standard properties available? Getting the tag URL that is created during the build would be incredibly handy. |
This comment has been minimized.
This comment has been minimized.
Hi,
Here is the bash test I wrote, in case it could help anyone: VERSION="$POM_VERSION"
IS_RELEASE=false
if [[ $MVN_RELEASE_VERSION != "" ]]
then
IS_RELEASE=true
VERSION="$MVN_RELEASE_VERSION"
fi
if [[ $IS_RELEASE = true ]]
then
# Do what you want for releases
else
# Do what you want for non-releases (so technically snapshots...)
fi [^1]: I don't remember where so I apologize for not quoting the guy who wrote this such useful trick on the comment I red |
Well one point to start documenting this, would be the Wiki ;-)
Wouldn't hurt to have this as a help page for the maven build step, either.