Publish try code in Jenkins before committing - eclipse

I have this development environment with Eclipse as IDE, SVN as SCM and Jenkins as CI server.
Is there a way I could start a Jenkins job from Eclipse and tell Jenkins somehow to take some code from my Eclipse workspace instead of the SVN? Without committing that code into SVN?
I know how to do the first part (start a job via Mylyn / Builds), but not the second one...
Maybe something like the way TeamCity is integrated into Intellij IDEA and the way they have facilitated gated commits...

It is not a good idea using local workspace for a continious integration tool in my opinion. Jenkins runs on a server machine in a standart configuration not in local machine. I think best practice for your scenario is using SVN branches for test committing. Configure a job in jenkins which works with the SVN branch to chechout the code. Add a svn hook for jenkins to compile after commit. Then integrate the branch to trunk after jenkins successfully build.

You can do anything with Jenkins.
Building code from my local machine in Jenkins is not a good idea though.
If at all you want to achieve this anyway, you can poll specific folder for any change and start building through Jenkins

Related

Switch branch in TFS when executing tests from Jenkins

If I have multiple branches in TFS for my automation code (QA branch, Beta branch, Live branch, etc.), is there a way to switch the branch being used when executing the tests via Jenkins?
I use Eclipse IDE and have multiple Maven projects set up in Jenkins that execute my tests. We use TFS as our source control at the moment.
I have different automation branches due to code base differences between environments and would like to be able to specify the automation code branch to use depending on what environment is being ran against on build time in Jenkins.
I am using a Choice Parameter for the environment. If I could set another variable off of that, maybe something like if env.contains("Dev") then set branchPath="QA" and then use the branchPath as the Project path in Source Code Management?
You can specify the project path in Source Code Management section of Jenkin, in Project path, you can specify the branch you need:

How to make SCM polling work with the Jenkins Workflow plugin

In a normal freestyle project, I configure the SCM plugin to point to the Git repo that I want to release, and I enable the "Poll SCM" option, which allows me to configure a Stash webhook to tell Jenkins whenever there has been a change to that repo. In this way, the job can be triggered whenever a change is pushed to the repo.
But when I use a workflow instead of a freestyle project, the SCM of the code that I need to build is specified programmatically in the groovy workflow script, which means that it is not listening for the Stash webhook. Instead, the SCM that is configured directly in the workflow is the SCM of the groovy script itself, which is different than the codebase that I am trying to build/release, so I don't want the trigger to be based on that.
node('docker_builder') {
git url: serviceRepo
releaseVersion = getVersion()
pipelineSpec = getPipelineSpec()
sh "./gradlew clean build pushDockerImage"
}
Any ideas about how to achieve SCM polling when using the workflow plugin?
I have resolved this question with lots of research and experimentation. This documentation got me on the right track: https://github.com/jenkinsci/workflow-scm-step-plugin/blob/master/README.md. It says:
Polling is supported across multiple SCMs (changes in one or more will trigger a new build), and again is done according to the SCMs used in the last build of the workflow."
This means that SCM polling is still supported with a Jenkins workflow, but unlike a normal freestyle project, you have to run it once manually before it starts listening for SCM changes. This makes sense because the SCM's are defined in Groovy code; they are not known until they run once.
One tricky element of this is that you can define many SCM's in your workflow. For example, I have three: one for the service itself, a deployment script, and the Groovy workflow DSL. By default, changes to any of those three SCM's would cause the "SCM poll" option to trigger a build, which may not be desirable. Luckily, setting the "poll: false" option on the "git" step in the Groovy code will disable polling on that repo. If you are reading your Groovy DSL from an SCM, then you can disable polling on that repo by clicking "additional behaviors" in the Jenkins UI and adding "Don't trigger a build on commit notifications".
Another tricky element is that the Stash web hook plugin by default includes the SHA1 hash code of the commit in the RESTful URL that it hits Jenkins with. Unfortunately, Jenkins makes the mistake of using that same commit code when it tries to pull any of the multiple SCM's that you may have defined. The hashcode is of course only relevant to one SCM, so it breaks. You can get around this by setting "Omit SHA1 Hash Code" in the Stash web hook plugin. Then Jenkins will just use the latest commit on whatever branch you build from in each of your SCM's.

Central compiling on a server

We are a team that works on liferay in eclipse.
We want to code in our clients but when we want to compile or deploy our code, this process done by server(to lower usage of clients and send main process to server).
How this can be possible?
You can use the Rundeck plugin for Jenkins to trigger a deploy based on the SCM commit message.
So your team would code and commit to a repository. Jenkins will then compile and deploy the latest build on the server.
BUT: I think I'd prefer to run my code on my client before committing it.

sonar+github integration

I want to enable sonar with git but is it neccesary that first pull the project from git repository using hudson or something else and then sonar will analyse the code periodically on hudson .am I right means my steps :
1.Pull project from git using hudson.
2.Sonar on hudson will analyse the code and send the updates.?
or directly we can use git+sonar how it works ,can anybody guide me to get it work.
Yes, you need first to pull your project from GitHub, and then launch a Sonar analysis on your local copy (Sonar needs the file to exist on the file system to be able to analyse them).
So you can pull your project manually or obvioulsy using a CI server like Jenkins/Hudson.
The good news, yesterday (2015-07-08) SonarQube has launched a Github Pluging, every time a pull request is submitted, the CI system launches a SonarQube preview analysis.
Reference:
http://www.sonarqube.org/github-pull-request-analysis-helps-fix-the-leak/

${CHANGES} does not work in the mail-ext plugin if jenkins job is driven by a bash script

I have setup a Jenkins job to build a project. I'm using email-ext plugin to send out build notifications with the intent of showing who did what and the path to the files changed. But unfortunately I'm not getting anything. I believe the reason why is that under "Source Code Management" I'm setting it to "None". My shell script that I'm using to drive the build is responsible for check-in out a copy of the code based on a CVS tag and run maven to do the build. In the ext-email i'm using the following syntax
${CHANGES_SINCE_LAST_SUCCESS, reverse=true, showPaths=true,
format="\n====\nChanges for Build # %n\n%c\n",
changesFormat="\n[%r] %d %a %m %p\n"}
Same thing with CHANGES: ${CHANGES, showPaths=true}
Is there a way of getting CHANGES and CHANGES_SINCE_LAST_SUCCESS to work if None option is used under Source Code Management?
Thanks for your help folks.
EmailExt plugin gets that info from Jenkins. As Jenkins has access to that info only via its SCM plugins the answer is "no", you can't do it without specifying the SCM option.
There are two things you can do:
(1) Do it by hand. Which with CVS, if I remember correctly, means having a working copy checked out anyway.
(2) Use SCM checkout/update option, but store the working copy on the side without using it in the build. You'll use twice as much disk-space, but nowadays disk-space is not a problem.
By the way, why are you using CVS? SVN, GIT, and Mercurial are all free.