Deploy Artifacts from jenkins Freestyle project

时间:2017-06-15 10:04:09

标签: java maven jenkins jenkins-plugins artifactory

I have a Jenkins job configured as a Freestyle project. This job is actually building a maven project but I have configured it as freestyle in order to be able to invoke a virtualenv builder (build steps) to run a set of regression tests written in python and shell.

Unfortunately it seems like the freestyle projects do not support the post build actions for deploying artifacts like normal maven projects do (referring specifically to the deploy artifacts actions). Any idea how I can workaround that?

On the other hand if I choose to build the project as a normal maven project then I cannot invoke the virtualenv builder therefore cannot run the regression tests.

I guess I could divide the build to two jobs, one building the artifact and deploying it to artifactory and the second retrieving it and running the regression tests. But this means that if the second job fails the deployed artifact must be removed. Which is not exactly ideal.

1 个答案:

答案 0 :(得分:0)

A freestyle job does support shell or bat post-build step in which you can type the command you want.

Here, a maven deploy-file command in order to deploy to your Maven repo (an Artifactory one)

mvn deploy:deploy-file -Durl=http://myartifactory/artifactory/repositoryId \
  -DrepositoryId=repositoryId -Dfile=target\my.jar \ 
  -DgroupId=org.group -DartifactId=art -Dversion=3.0-SNAPSHOT -Dpackaging=jar

If you know your GAV during the job, you can deploy it through command line.