Thanks for all the suggestions.  I've not been successful yet in updating
the POM to get what I need.  The deploy seems to assign a new snapshot id
(timestamp+iteration) independent of what is set in the project.

My most successful attempt so far is to not worry about it in the POM, but
instead immediately use the RestAPI for Nexus OSS with the GAV coordinates
and the resulting XML (or JSON) contains all the information I need.

I'm currently working on a Groovy script that will take the JSON and set
Jenkins Job environment variables.

FYI, the RestAPI looks like:

http://
<nexuxHost>/nexus/service/local/artifact/maven/resolve?r=<REPO>&g=$POM_GROUPID&a=$POM_ARTIFACTID&v=$POM_VERSION&e=$POM_PACKAGING


Where the $POM_** variables are the maven coordinates that are set in a
Jenkins environment for a Maven job.  The json result looks like:

{
    "data": {
        "presentLocally": true,
        "groupId": "<groupId>",
        "artifactId": "<artifactId>",
        "version": "<nexusSnapshotVersion>",
        "baseVersion": "<version>",
        "extension": "<packaging>",
        "snapshot": true,
        "snapshotBuildNumber": 120,
        "snapshotTimeStamp": 1440115538000,
        "sha1": "af6be177f975966800777d62afd3081f412b4286",
        "repositoryPath":
"/<groupid>/<version>/<artifact>-<nexusSnapshotVersion>.<packaging>"
    }
}


This is everything I need/want so hopefully I can figure out how to set
Jenkins job settings. ;)

-Jeff


On Mon, Aug 24, 2015 at 7:51 AM, Ben Podgursky <bpodgur...@gmail.com> wrote:

> Ok I'll stop spamming after this.
>
> Try ${maven.build.timestamp}, seems like it might already be the same
> snapshot as the timestamp and set by maven. (
> https://dzone.com/articles/stamping-version-number-and)
>
> On Mon, Aug 24, 2015 at 6:44 AM, Ben Podgursky <bpodgur...@gmail.com>
> wrote:
>
> > ack, actually that isn't the snapshot version, it's the git commit.  But
> > it's the closest thing I know of.
> >
> > On Mon, Aug 24, 2015 at 6:42 AM, Ben Podgursky <bpodgur...@gmail.com>
> > wrote:
> >
> >> Sorry for the late response,
> >>
> >> I think you can use this plugin:
> >> https://github.com/code54/buildversion-plugin
> >>
> >> "build-version" property will be the snapshot version.
> >>
> >> On Mon, Aug 24, 2015 at 1:52 AM, Gerd Aschbrenner <
> >> gaschbren...@picturesafe.de> wrote:
> >>
> >>> Hi Jeff,
> >>> I have no answer for your question, but maybe I have got a solution for
> >>> your problem.
> >>>
> >>> But you will be limited to only one running instance of your Jenkins
> >>> build pipeline.
> >>>
> >>> Take a look at the plugins:
> >>> * Copy Artifact Plugin
> >>> * Clean Workspace Plugin
> >>>
> >>> 1. Build your "myapp" with Jenkins
> >>> 2. Add the post build action "Archive Artifact"
> >>> 3. In the downstream project add a build step "Copy artifact from
> >>> another project"
> >>>
> >>> Now the artifact is in your workspace and you can work with it.
> >>>
> >>>
> >>> So what about the "Clean Workspace plugin"?
> >>> It is for stability. You can use it to clean the whole workspace (or
> >>> only the copied artifact of the previous build) before copying the
> artifact
> >>> into your downstream project.
> >>> This will ensure using a fresh copy of the artifact and not any old
> >>> (cached) build of it.
> >>>
> >>>
> >>> I use this plugins to collect some "last stable" artifacts from
> >>> different Jenkins projects and copy them to a test environment
> >>> (publish-over-ssh plugin).
> >>>
> >>>
> >>> Regards
> >>>    Gerd
> >>>
> >>>
> >>>
> >>> Am 21.08.2015 um 17:08 schrieb Jeff:
> >>>
> >>>> I should clarify that I want to find the specific SNAPSHOT version
> >>>> assigned
> >>>> by Nexus (or other maven repository manager applications) after the
> >>>> deploy.
> >>>>
> >>>> So after I deploy 'myapp.jar' to Nexus with GAV:
> >>>>
> >>>> groupID: mycompany.com
> >>>> artifactID: myapp
> >>>> version:  1.0-SNAPSHOT
> >>>>
> >>>>
> >>>> Nexus assigns it to something
> >>>> like
> /com/mycompany/myapp/1.0-SNAPSHOT/myapp-1.0-20150821.000538-120.jar
> >>>>
> >>>> I want to get the "20150821.000538-120" portion and also if possible
> the
> >>>> SHA1 hash Nexus generated.
> >>>>
> >>>> Thanks!
> >>>>
> >>>>
> >>>> On Fri, Aug 21, 2015 at 8:37 AM, Jeff<predato...@gmail.com>  wrote:
> >>>>
> >>>> In implementing a continuous deployment pipeline I would like to
> update
> >>>>> my
> >>>>> configuration tool with the specific SNAPSHOT version produced during
> >>>>> the
> >>>>> 'deploy' phase of the build.
> >>>>>
> >>>>> Ideally, I'd like to set an environment variable so that in Jenkins I
> >>>>> can
> >>>>> use it to trigger the downstream build.  Alternatively a file or
> >>>>> something
> >>>>> will work
> >>>>>
> >>>>> I've been searching Google and digging through the archives, but I
> >>>>> haven't
> >>>>> found a way yet.
> >>>>>
> >>>>> Is there a way to do this somehow using existing plugins or Maven
> >>>>> conventions?
> >>>>>
> >>>>> Thanks!
> >>>>>
> >>>>> --
> >>>>> Jeff Vincent
> >>>>> See my LinkedIn profile at:
> >>>>> http://www.linkedin.com/in/rjeffreyvincent
> >>>>>
> >>>>>
> >>>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> >>> For additional commands, e-mail: users-h...@maven.apache.org
> >>>
> >>
> >>
> >
>



-- 
Jeff Vincent
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

Reply via email to