I am currently working on a custom Maven plugin that generates a build artifact in the form of a zip file with a dynamic version or build number. The format of the file is something like
target/[artifactId]_[version or build].zip
Where [version or build] parameter is dynamically generated based on a snapshot of time, (Eg. [changeset24]-[changeset57]) on a parameterized Jenkins build where the user of the build will not necessarily know the latest changeset. The plugin uses an API to determine the latest changeset, for example changset57, and then uses the starting changeset parameter to form the unique version/build of the zip artifact.
This is meant to be a solution for streamlining the chaotic and manual process we face in our enterprise around delta based SQL scripts on hugely complicated schemas. There is no clear promotion path up through environments for a single versioned database artifact. It is a long story with a very immature devops organization and many frameworks and skill sets that do not mesh well, so I will spare the rest of the details here.
Ultimately we need to specify not the JAR artifact for this build to upload to Artifactory, but the ZIP file that is being created here, however Maven does not seem to allow for us to change the hard coded <version>
in the POM file, and even if we could, we need the ability to:
- Run the Maven build with custom plugin execution goal
- Parse the output file for the unique version number that is generated
- Override the
${VERSION}
or${BUILD_NUMBER}
environment variables in Jenkins - Upload the artifact to Artifactory with the new environment variable for version or build number being included in build info.
The problem I have is that I seem to have trouble figuring out how to configure these 4 steps with the existing Maven3-Artifactory Jenkins plugins, nor with the Generic Artifactory Plugin using FileSpec JSON. I don't see how I can inject a custom shell script to override environment variables here either between this process.
Does anybody have any good suggestions of how I should configure this job?
NOTE: Please don't suggest that my general approach is fundamentally bad or flawed or whatever. That is not helpful because I am facing numerous technological and political constraints that prevent a more appropriate solution.