I'm using mvn install to build the .hpi to my plugin for Jenkins. This puts a .hpi in the target folder.
What I would like to do is if the build is successful, copy the hpi-file to a specific folder. Is it possible to do both these task with one Maven command using only the terminal/command prompt?
edit
My POM can be seen here.
https://github.com/MarkusDNC/plot-plugin/blob/master/pom.xml
There is now way to copy file through MVN CMD.
After that being said - You have 2 options:
1.) using a simple shell/batch step to copy.
2.) You need to Add another build step for maven but you will also need a new pom.xml file and use maven-antrun-plugin
Related
I have a maven project to create a zip file which can be used to upgrade the applications we distribute. When mvn package is executed this will gather required dependencies and bundle with some PowerShell scripts which does the upgrade. I want to create a checksum for the generated zip file.
When i searched over internet i got two solutions one is to use -DcreateChecksum=true option for the mvn install plugin. This zip file is big and we don't want to copy this to maven repository hence we don't execute this goal. Another option is using checksum-maven-plugin, but this will create checksum for artifacts which i don't want. It also has a command line option mvn checksum:file -Dfile=some-file.zip but this has to be executed manually. I want to add this to my pom so we don't have to manually create checksum. Is there any clean way other than creating a script to create checksum and calling it.
I am using mvn archetype:generate -B ... to generate a maven project.
It places the generated project in the current working directory.
Can this be customized to place the generated project in a directory I specify? I don't see any options to do so in the command line --help menu.
You cannot specify a directory for archetype:generate, this plugin always targets the current working directory.
The Maven Archetype docs suggest using the basedir parameter. Something like this perhaps:
mvn archetype:generate
-DgroupId=foo
-DartifactId=bar
-Dbasedir=/some/other/directory
But, unfortuntately that doesn't work, even with that parameter specified the archetype is generated into the current working directory. Looking at the Maven Archetype JIRA I can see that there is an open issue for this:
https://issues.apache.org/jira/browse/ARCHETYPE-311
This issue has been open since April 2010 and it has been raised against version 2.2.0 of the archetype plugin and I have just verified that this issue still exists with in latest version of the archetype plugin, the following command completed but created bar in the current working directory rather than in /some/other/path ...
mvn org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
-DgroupId=bar
-DartifactId=foo
-Dbasedir=/some/other/directory
So, if you want to use archetype:generate and you want the generated project to exist somewhere else then I think you might have to write a simple script which ...
Invokes the plugin
Moves the created directory to your desired location once the plugin has finished running
-Dbasedir doesn't work.
You could specify output directory by passing -DoutputDirectory=/some/other/directory
Here's the documentation
https://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html
I am unable to edit pom.xml. Is there a way to define final name of the maven artifact built by Hudson, something like this
<finalName>${project.artifactId}-${project.version}-${timestamp}</finalName>
Since mvn -DfinalName="xxx" on command line does not seem to work.
I am looking for Hudon/Jenkins feature to achieve this as well, or modifying settings.xml in maven repo. Basically any method except editing pom.xml
First, you could have a second build step (execute shell or windows batch) to simply rename the artifacts. Obviously, this will forego the automatic maven module artifacting, but are you using that? If not, just archive the file with post-build actions directly on Jenkins or repository of choice.
Second, the moment you check out the files from SVN, you do have access to modify them in your local workspace. Just don't commit them back to repository.
You could run a regex replace to look for <fileName>.*</filename> and replace with whatever you want.
I'm trying to move an existing ANT build script (build.xml) into Cloudbees for CI using Jenkins. I setup the project repository using GitHub. The build pulls the repository into the Cloudbees Workspace successfully, but then fails with this message.
Parsing POMs
ERROR: No such file /scratch/jenkins/workspace/project/pom.xml
Perhaps you need to specify the correct POM file path in the project configuration?
I'm not too familiar with this, but from what I can tell (thanks Google) it's because Cloudbees uses Maven instead of ANT. Is there a way that I can change Jenkins to run the ANT build script instead of using Maven? Or a simple way to execute my ANT scripts from Maven? Any help here would be appreciated!
Thanks
You do not need a Maven POM file if your project is Ant-based.
It sounds like you created a Maven job in Jenkins. Delete it and create a free-style job instead, then (as #thekbb says) click Add build step and select Invoke Ant and configure as needed.
ant support is provided by teh ant plugin, I think you get this automatically when installing jenkins. In your jenkins job, add a build step of type 'Invoke Ant' and provide the target.
I run test cases from jenkins with testng and i export the results in test link thanks to TestLink Plugin.
I have a little problem, since yesterday i try to get the test cases using git. I can download all the git repo, but when i build the project in jenkins, maven try to compile all the files downloaded from git repo (about 4500 files) and i have only 5 test cases at the moment ...
my Git repo looks like
Folder 1 -> ...
Folder 2 -> ...
FolderTest->src->MyTestCasesAreHere.java
Is there any way to specify the path of the test cases, or to make maven compile only the files i want ?
i "invoke top level maven targets" with maven targets :test -DsuiteXmlFiles=suite.xml
is it the right way?
If you are just trying to build a subproject change the Root POM option under the Build section of your Jenkins job configuration. This is assuming that you are using the Maven2/3 job type.
Also, if that doesn't work think about passing in the -f command line option to Maven to control which POM your build is going to use: http://www.sonatype.com/books/mvnref-book/reference/running-sect-options.html