Transform a Maven snapshot artifact into a release when promoting a build

963 views
Skip to first unread message

Maxime Lemanissier

unread,
Sep 23, 2011, 11:23:35 AM9/23/11
to Jenkins Users
Hi all,

I'm using Promoted build plugin. I would like to get the distribution
artifact (a tar.gz) of a build transformed into a release (assign a
unique Maven version number based on SVN revision and Jenkins build
number and move this into my Nexus release repository) when I promote
a build.

I was considering using "deploy maven artifacts to repository" task
for promotion action, but this fails with an error :

No artifacts are recorded. Is this a Maven project?
build
hudson.plugins.promoted_builds.tasks.RedeployBatchTaskPublisher@3230d05a
FAILURE

I think it's because promotion implies a fresh build / workspace, and
so, the promotion plugin does not find the artifacts that were built
during the build I want to promote.
I activated "archive artifacts" for this job but this does not help.
Wondering how can I get the archived artifact corresponding to the
build i want to promote back into the workspace of the promotion
build...

I could use a custom script and call a mvn deploy:deploy-file on the
archived artifact, but I have to get the path of this artifact and I
don't know how...

Do you know a way to use promotion for transforming snapshot into
release ?

Maxime Lemanissier

unread,
Sep 23, 2011, 6:29:48 PM9/23/11
to Jenkins Users
OK, I found a way.

Activate archiving on pom.xml and target/*.tar.gz

Run a shell script on promotion:

wget ${PROMOTED_URL}artifact/pom.xml
wget ${PROMOTED_URL}artifact/target/deliverable.tar.gz

mvn deploy:deploy-file -Dfile=deliverable.tar.gz -DrepositoryId=repoId
-Durl=http://... -DpomFile=pom.xml -Dversion=${BUILD_NUMBER} -
Dpackaging=tar.gz

Maxime Lemanissier

unread,
Oct 11, 2011, 8:39:15 AM10/11/11
to jenkins...@googlegroups.com
Hi,

I just got an email from someone asking for details about this script.
I made some modifications since. Instead of getting artifacts through wget,
I promote directly those stored in Jenkins archive folder. The script is
also managing multi-modules projects now.

There are 2 scripts :
- The main script : http://pastebin.com/5A75i1aM
- The script for promoting an artifact (called by main script for each
module) : http://pastebin.com/6ynJCjYm

Ideally, this should be a Jenkins plugin instead of some bash scripts...
If I find time, i'll try to do this.


--
View this message in context: http://jenkins.361315.n4.nabble.com/Transform-a-Maven-snapshot-artifact-into-a-release-when-promoting-a-build-tp3837168p3894120.html
Sent from the Jenkins users mailing list archive at Nabble.com.

Maxime Lemanissier

unread,
Oct 11, 2011, 8:48:36 AM10/11/11
to jenkins...@googlegroups.com
Here is an example of the console output of a promotion build on a
multi-module project, producing tar.gz and war mixed up :
http://pastebin.com/uw2gfGrT

--
View this message in context: http://jenkins.361315.n4.nabble.com/Transform-a-Maven-snapshot-artifact-into-a-release-when-promoting-a-build-tp3837168p3894159.html

Reply all
Reply to author
Forward
0 new messages