Let Jenkins build a maven project from Perforce - maven

I am trying to set up a Jenkins server to build Maven projects stored in a Perforce Depot but I am failing the setup of the Perforce plugin.
That's what I have (regardless of Jenkins):
A running Perforce server with my Maven Project in a depot //components/myjavaproject/main (that's the path where the pom.xml is.
A Perforce user p4javabld with a client spec called p4javabld-cqm1
The client root is set to D:\p4client\p4javabld
When I set up a Jenkins project I set
P4PORT to my perforce server,
Username to p4javabld
Workspace to p4javabld-cqm1
I did not allow Jenkins to create any new Workspace or Workspace View
Client View type to stream with the stream //components/myjavaproject/main
On the config page I get Unable to check workspace against depot and Unable to check stream against depot
When I run a build it executes a
p4 changes -s submitted -m 1 //p4javabld-cqm1/...
which makes no sense I think. It seems then to scan the complete Perforce depot and seems not to concentrate on //components/myjavaproject/main
What is the configuration error?

I was able to let Jenkins build a Maven project from Perforce. I used the P4 Plugin instead of the Perforce Plugin. Then I configured a manual workspace with a workspace view to
//components/myjavaproject/main/... //p4javabld-cqm1/...
having the pom.xml in the root of //components/myjavaproject/main/

Related

Pulling existing project settings from .teamcity folder in VCS to new TeamCity Server

I've configured our current TeamCity instance to use Versioned Settings and these have been pushed to the .teamcity folder at the root of our repository.
I'm now configuring a new TeamCity instance and would like to set the VCS root of the _Root project to be my current repo and have it synchronise in all the current settings.
I've configured the VCS on the Root Project, and enabled versioned settings which informs me that the repo contains project definitions and would I like to import them. I choose to import them and this results in me getting the following error message.
Current Status:
[13:16:17]:
Failed to apply changes from VCS to project settings (revision 40715d54dc3d66486e90eaec9d105809dfe0224e): Remove of the project where versioned settings are defined via commit is not supported, you can remove the '<Root project>' project in UI. Please fix the errors in VCS and commit again.
Now the message suggests that I should delete the <Root project>, which doesn't seem correct. I'm guessing the issue is that the .teamcity folder already contains a definition for the Root Project and somehow this is conflicting with the new Root project.
Is what I'm trying to achieve here possible?

Maven test-output folder is not updated with the build results(emailable-report is not updated after the build is successful/failure with the result)

Scenario: Send an email after the build with the emailable-report.html.
Am able to achieve the above scenario.
But when the build is completed in jenkins, target folder or test-output folder is not updated after build. which means the jenkins workspace is not updating the target folder or test-output folder after the build. Rather the Jenkins workspace remains with the code checked out from GIT repository.
I want the jenkins workspace to be updated after the build to email the latest emailable-report.html.
Script for the sending the email:
def reportPath = build.getWorkspace().child("test-output/emailable-report.html")
msg.setContent(reportPath.readToString(), "text/html")
Help me with this scenario.
This is just because build is generating in wrong jenkins workspace due the wrong configuration that we have done earlier.
It should be something like
C:\Users\Ashv\.jenkins\workspace\projectname
and for this make sure the below configuration.
Goto Manage Jenkins>>Configure System>>Advanced
Home directory C:\Users\Ashv\.jenkins
Workspace Root Directory : ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}
Build Record Root Directory: ${ITEM_ROOTDIR}/builds
here I am attaching my job screen for all configuration I have done.
you can find the link of image

Jenkins- SVN poll won't work if take checkout using shell script

We have a maven project for which we have set up jenkins for build. The reporsitory has a large tools folder which i didn't want Jenkins to download.
I just want jenkins to download src folder and pom.xml file.
I added two reporsitory locations in Jenkins - only to learn that Single file checkouts are not possible
This forced me to use shell script option provided by Jenkins for checking out pom .xml . PFB the script outline.
svn checkout $pomUrl . --depth empty
svn update pom.xml
I did not find an option in my scm plugin of Jenkins to do an empty checkout
Checkout one file from Subversion
But POLL SCM of jenkins is only polling the src folder and builds are not triggered if i make some changes to pom.xml. Is there a way to ensure Polling of my pom.xml as well?
No. Jenkins will poll what it knows.
In your scenario:
Jenkins doesn't know about your pom.xml.
Jenkins doesn't work in single file checkouts anyways.
You will have to rearrange your structure, either move the tools folder outside of the main checkout (if it's so large that it's prohibitive, why do you have it in the root location?), or move the pom.xml into the src folder.
Edit:
Here is an idea. Haven't tried so don't know if that will work.
Keep your manual checkout and update of that pom like you currently do.
Setup another SVN Add module....
Enter the root location of SVN where your pom is, give it a non-conflicting folder name
Configure Repository depth for that module as Empty (if you don't see this option, you may need to upgrade your SVN plugin and/or Jenkins).
Click Advanced... section.
Configure Included Regions with the path to your src folder, and the pom only.
Something like:
/trunk/myapp/src/.*
/trunk/myapp/pom.xml

Using TeamCity to build local project in order to test setings

I want to experiment with my project output on the TeamCity. I dont want to use git or any other version control system.
Is there a way to turn off the VCS in teamcity and make it build and execute local projects.
Just install TeamCity on your machine, up to 20 build configurations it's free. VCS roots are completely optional, you can just build solutions from a local path - VCS roots are just a means to getting your code locally from a repo so you can build / interact with it.

Create job in jenkins with calling svn and maven

For now I have a batch file with commands for update projects using svn and calling maven 'clean install'. How to create some job in Jenkins for similar actions?
Should I write it to ant file (sorry if it's stupid idea, I've just heard about it but I don't know what is it exactly and what can I do with this) or there is other way?
Thanks
Like arghtype suggested, you need to be using Jenkin's own Source Code Management by configuring SVN as SCM source and supplying credentials as part of Maven build job.
If you have to use your own local working copy, you are organizing it wrong, you will lose on all the benefits of having Jenkins manage SVN changes, and in the end, this organization will give you more unsolvable problems in the future. Think about the advice people are giving here and come with up a reason why you need to have a local workspace outside of Jenkins management on a Jenkins build machine. My only guess is: your Jenkins and Development machine are the same. That again is not how it should be organized. Jenkins is a CI-server, not a personal build "automator".
Regardless, if you still want to do what you say.
What you think you want
Create a new Freestyle job
Under Build Steps, click Add build step
Select Execute Windows batch command
Write your batch execute command in there. Your working directory will be Jenkins's $WORKSPACE, so change your path accordingly to where you want to run it.
But with the above configuration, you might have as well put the batch file under windows scheduler... You are not really using Jenkins with the above.
What you should do instead
Create a new maven2/3 build job
Under Source Code Management, select Subversion
Under Repository URL enter the remote SVN repo (i.e. http://your.svnsever.com/path/to/project)
Under Build, enter your Root POM location (this will be relative to the location of your SVN checkout, so if your POM is under http://your.svnserver.com/path/to/project/maven/pom.xml, then enter maven/pom.xml.
Under Goals and options, enter clean install
Click Save
The Source Code Management section will take care of setting up a local workspace and checkout the repository into that workspace. By default, every time a new build is triggered, it will run svn update on that workspace for you.
The Maven Build step will take care of running your Maven, however note that it is configured to use default ~/.m2/repository location. If your local maven repo needs to be different, change this under Jenkins Global Configuration
Create a new job.
In Source Management choose Subversion, specify your repo and credentials.
Add a new build step - maven build, specify your maven goals ('clean install').
Jenkins is a CI(contiounus integration) server. It can be used to generate scheduled builds of ant or maven based projects. It can also start building projects by some triggering event such as a commit to SCM (git, svn, mercurial,...)connected to it. You really have to read its documentation to get a better understanding. It has nice tutorials.

Resources