I use Hudson to do continuous integration on some maven projects. For these projects, I would like to have the pom description used as content for the Hudson job description. is there a solution to automatically have this configured ?
That's a bit hard to do because Hudson needs the config so it can checkout the POM. What you can try is use the command line API to configure the project.
Another solution is to run mvn install site. That will generate the web site for the project and Hudson will present a link to it right below the description, so you can use this description:
This is a Maven project; click the link below to visit the web site.
You can just run mvn site no mvn install needed to see the link about the generated site in Hudson.
Related
I am new to Jenkins.
I have automation scripts designed in Selenium as Maven Project.
I am able to trigger the build (execute POM.XML from GIT repository) from Jenkins.
My current Flow is as below.
Eclipse -> GIT ->Jenkins (trigger POM.xml available in GIT).
This approach is only for the test team wherein the push the selenium code changes to GIT branch and the code is tested by executing the POM.xml file.
I want to include the Deployment step (for DEV team) in this cycle. So that the automation script executes on the latest deployment. So the flow should look something like below.
Eclipse (Dev code) -> GIT repo -> Jenkins (build) -> Jenkins (deployment in test environment) -> Jenkins (trigger POM.xml available in GIT)
This way I would be able to execute my POM.xml on every latest build.
Any help will be appreciated.
If you are a novice with Jenkins, start playing with it and download and install localy (https://jenkins.io/download/).
It is not that much to it. Here are a few simple steps.
install Jenkins, and probably have Maven, Java,
setup path in Jenkins to Maven and Java in Global Tool Configuration section ins Jenkins settings,
create a new Freestyle job,
connect to git to the desired project on git,
In section, build triggers add maven command like in console (without mvn) as "Invoke top-level Maven targets" with commands from maven like install, test etc.
Start job.
Hope this helps.
Jenkin has integration with Maven via Maven Plugin so
If you're using a freestyle project just add the relevant build step in Jenkins GUI
If you're using Jenkins Pipeline - declare your test execution via Pipeline Maven Plugin like:
node{
stage ('Automation') {
git url: 'https://path/to/your/test/repo'
withMaven(
maven: 'maven-3',
mavenSettingsConfig: 'my-maven-settings') {
sh "mvn clean test"
}
}
}
Be aware that Jenkins might not have GUI therefore you may need to either use headless browsers versions or install extra software to simulate display like Xvfb
I just figured out, how to release to CB hosted maven "release" repository. I am trying to figure out, how to deploy tagged version to CB application.
I understand, I can manually upload WAR file but is there any script. As far as I know maven plugin for CB doesn't support it.
I have one appserver is running snapshot builds from jenkins.
I have other appserver, which I want to deploy only tagged/released artifact.
There are four ways to deploy applications to the CloudBees RUN#cloud service:
Using the bees command provided by the SDK
Using the bees-maven-plugin
Using the manual upload via the web GUI
Using the CloudBees Deployer plugin for Jenkins
Which option you choose depends on where the deployment will take place from... And the from I am talking about is which machine is doing the deployment not where the file is sourced.
If running from a Jenkins job, the best bet is the Jenkins plugin.
If running from your own laptop, the web ui or the bees command is simplest.
If running as part of a maven build, the maven plugin is simplest... (Though I should warn that the maven plugin (temporarily removing my cloudbees hat and putting on my maven PMC hat) is shite and does it all arsewise ;-) )
Your best bet is to set up a Jenkins job that uses dependency:get to pull the artifact from the repo and then add a cloudbees deployer build step to push to RUN#cloud
The good news is that bashing the maven plugin into something more maven like is on our roadmap... Hopefully that will enable actions like you can achieve with the ship-maven-plugin#mojo where you can specify a specific released version for "shipping" to production.
I suppose, that what you want to do is to deploy a release artifact to your repository.
have a look at maven-release-plugin.
Briefly, what you need to do is:
$ mvn release:prepare
$ mvn release:perform
it's not so trivial, since you need to configure appropriately your pom.xml to get it working. Have a look at the maven-release-plugin examples and usage pages.
Are you creating the tag/release from a Jenkins build? If so you could probably use the Deploy to CloudBees post-build step with target/checkout/something.war.
More generally I guess you would want to write a script to use mvn dependency:get followed by the Bees SDK to obtain the latest released artifact and deploy it.
With CloudBees now supporting deployment of Java applications, is it possible to use the post-build action in Jenkins "Deploy to CloudBees" to deploy your app? Furthermore, I'd like to use the Maven assembly plugin's jar-with-dependencies goal so that I can simply and automatically deploy my entire app to CloudBees right through Jenkins.
While the current CloudBees deployer Jenkins plugin appears to not support this, in fact it does. Here are the steps that after much trial and error worked for me:
Include the jar-with-dependencies maven plugin in your pom.xml. I used the <goal>single</goal> and <descriptorRef>jar-with-dependencies</descriptorRef> described here. That will put an additional jar file in your target folder {artifactId}-{version}-jar-with-dependencies.jar
Deploy that jar via the CloudBees API. The last line of this page explains how to do that. Specify your runnable jar, make sure the runtimeContainer=java, and the jar file to be uploaded, and it should deploy. Even though CloudBees says to use a zip file, a jar file works just fine.
Once that has been deployed once via the command line, your app ID now "remembers" those settings so that it can be done via Jenkins so long as you're doing the CloudBees Deploy to that same app. In your Jenkins job, add the "Deploy to CloudBees" Post-build action to your configuration. Click "Add Web Application" (strange, I know, since it's not a web-app! CloudBees says they will work to change that...), select First Match (even if it's a Maven project, use First Match), enter your application ID that you deployed your app to in step 2, and then enter the full name of your jar file and try your build again. It should upload your jar file and activate the instance in your CloudBees PaaS. Note that this still hard-codes the version in the jar file - I am working to see how to setup a variable for the version of the jar file so that it corresponds to the Maven build version.
Once you have it setup correctly and deployed initially with the bees sdk, it should just deploy from the deployer plugin on Jenkins as a war normally would.
Once set up, the settings that define where your main class is persist between deploys.
I have done an mvn install for a custom plugin and it gave me a bunch of directories in my target directory along with a jar. I'm stuck with the next step.
How do I bundle it?
Where do I place this?
What about the pom of this plugin?
What configuration changes do I have to make and where?
You can always test it on your local machine. Just run mvn clean install and it will be installed in your local repository. Then in the project you'd like to use it from, just add the plugin to the plugins section and set it up like any other plugin. This should be enough.
If you'll be using it in your company, you'll need to be able to deploy it to a Maven repository such as Nexus or Artifactory in order for other people to be able to download it.
Deploying it is the same as for regular artifacts:
mvn clean deploy
I'm using Hudson and Maven 2 for my automated build/CI. I can build fine with maven from the command line, but when I run the same goal with Hudson, the build fails complaining of missing artifacts. I'm running Hudson as a windows XP service.
Obvious question, but have you got Hudson set up to point to the same Maven repository as your command line build? You can check this from the Hudson admin gui - look in the Maven section of the Manage Hudson page. This should have a MAVEN_HOME environment variable listed. Look in the settings.xml file under:
MAVEN_HOME\conf\settings.xml
The localRepository configuration item is the location of the Maven repository that the Hudson build is using.
Make sure you're running Hudson as the same user that you are using to run Maven from the command line. Maven creates a separate repository for each user. If you are running Hudson as a Windows service, this won't be the same user as you have logged on as and will be running "mvn" commands with. This means the artifacts in the repositories may be different.
To fix, either start Hudson manually as the user which works, or update the repository for the user which Hudson is running as.