How to configure Auto Commit in build step - java

I'm using TeamCity plugin with IntelliJ and working with the following workflow:
https://confluence.jetbrains.com/display/TCD10/Pre-Tested+%28Delayed%29+Commit
My concern is if this process can be automated in a manner that the last step which says "commit my local patch if the build succeeded" and the step will be done on the TeamCity side and not on my local laptop.
Can I add some extra step in the build that says "If the build succeeded commit this patch to SVN" (from the TeamCity server)
It just feels like the wrong way that the server needs to keep a connection with my laptop until the end of the build.
It causes a lot of commit failures due to network glitches, authentication failures, files with other revision etc.

This set up is not possible, as TeamCity is not aware of your local version control credentials and settings, that will be used during commit from the IDE.

Related

How does sonar:sonar work?

We want to use SonarQube with some CI tool in our project. Sonar Server url is configured in main pom.xml.
There are several team memebers in the project. So what happen when one team member executes sonar:sonar locally with his local changes, then another team member executes sonar:sonar with his local changes, and then someone executes sonar:sonar from CI tool (it is configured to analyse source code in Git repository)?
Will SonarQube display issues related team members local changes? What if there are differences between team members local source code and source code in Git repository?
sonar:sonar executes analysis and sends the results to the server - assuming you're running it with the token of an account that has the appropriate privileges.
Developers should not be running this type of analysis locally to check their changes. Instead, they should be using SonarLint and perhaps pull request analysis (depending on your infrastructure).
(EDIT: Pull request analysis has been deprecated and replaced by a fuller-featured Branch analysis($).)
To expand a little on why developers shouldn't be using sonar:sonar locally: it updates the central server in a last-saved-wins manner. So if you've edited A.java and analyzed it locally before commit, and I've renamed A.java to B.java and done a similar pre-commit local analysis... what's visible on the SonarQube server? Depends on who saved/analyzed last.
Instead, sonar:sonar should be run only from your CI tool on the checked-in code that's already visible to the whole team.
As you said that sonar server url is cofigured in mail pom.xml and your team member's run sonar:sonar command at there local machine. But because of all referring to the same server url. So all changes will reflect for a common project. If you want to see then difference separately for each team member. then either you need to update the project name distinct from each other. Other wise you will see latest one there.
Sonar gives you difference in graphical manner. as well as you can compare two build too.
Second If user has administrator grant only then they can update sonar server else not.

How to deploy a Java web aplication on OpenShift or Git?

I have created a web site using NetBeans IDE by File -> New Project -> Java Web -> Web Aplication using apache-tomcat-7.0.67 as my Server.
The website consits of 3 .jsp pages, 1 servlet and 1 javaBean and json.org (extension is .jar)
Now I'm trying to deply it on http://app1-lolcheck.rhcloud.com/ but I have no idea how both to use git or Openshift.
I've installed git, ruby and OpenShift rhc Client Tools.
Finally I have already done what this video says (but using Tomcat 7 (JBoss EWS 2.0)) : https://www.youtube.com/watch?v=vbvOQ2gopwo
So what should I do?
Victor,
I will try my best to answer your question in the general steps needed rather than the exact steps which will require some configuration.
If you log into your OpenShiftAcount and go into your developer portal you can go into your applications settings. Among other things, listed there will be git address.
What you will need to do is, assuming you have downloaded git, set it up following these steps:
Getting started with git
Then you need to go into your project directory and initialize the git there using:
git init
then add everything in your project folder except what's included in .gitignore (more details on the link that i provided you)
git add .
then commit everything
git commit -m "Some commitment message here."
now you need to add the application git address to your git's origin
git remote add origin [git address like git#github.com:user/gitname.git]
then you deploy using
git push origin
There are a lot of things I did quick and dirty and the actual configuration of the projects for rhc will need to be done by changing some settings file or in some cases procfiles. With everything that you need to get used to, please use this as a guideline for solving your problem.
A good crash course on git is going to be very helpful in any development work with version control and especially so with web development since so much deployment is done using git.
I am by no means a git expert, not even close to it, but I do use it in android development, web development and recently even in arduino programs just becasue of version controlling it offers.
To remove existing remote origin
git remote rm origin
Then you can add it one more time using the git remote add I mentioned above.
Git and OpenShift are two different things. Git is a version control software, like CVS or SVN. OpenShift is a PaaS provider, like Google App Engine. OpenShift is using Git to manage the deployment.
Your link shows that you've successfully created and deployed a running web app. The next thing you want to do is clone the source from OpenShift to your local disk, make changes and do a git commit and push your changes to the OpenShift cartridge. Your cartridge already has scripts that will be automatically be triggered to deploy your changes.
Follow these steps:
Netbeans > Team > Git > Clone:
Give your Repository URL. something like ssh://app1-lolcheck.rhcloud.com/~/git/.... (Hint copy it from your application page on openshift...see on right side under "source code")
username will be automatically filled
provide private/public key (you can get from settings menu on openshift website)
select master branch and in next step give parent directory where you want to clone and finish. Now copy your project contents in that directory...
right click on project in netbeans, click git > Commit
Then right click again your project > Git > Remote > Push. Done
Application will be deployed within few minutes.

Triggering a Git fetch, reset using Jenkins

I have a Java package which is checked in Git (and code.amazon.com) and I have a Ant job to trigger the package. Within the Ant job, I have created a macrodef for Git and I am performing a git fetch and git reset so that I can get the latest codebase every time I am triggering the Ant job.
When I am triggering the Ant job using Eclipse, it is working. If I am running the Ant job from terminal using ANT –buildfile my_buildfile.xml, it is also working.
Now I have setup Jenkins on my machine and am trying to run the Ant file. Jenkins is not able to trigger the Git job in the Ant file. It is giving following error:
/rhel5pdi/workplace/bangshis/EpubYJConvPerfWorkspace/src/EpubYJConvPerfLinux/Jenkins_Linux_build_Global.xml:81: The following error occurred while executing this line:
/rhel5pdi/workplace/bangshis/EpubYJConvPerfWorkspace/src/EpubYJConvPerfLinux/Jenkins_Linux_build_Global.xml:99: Execute failed: java.io.IOException: Cannot run program "git": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at java.lang.Runtime.exec(Runtime.java:617)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:628)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:669)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:495)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Part of this error might be due to the reason that, my Jenkins is not able to trigger the job as the current user of the host machine.
To solve this problem, I have tried taking the following steps:
Creating a global credential and using password-less account (RSA ID).
Logging into Jenkins using the same username as system.
Installing Git and Git client plugins and setting them up appropriately.
Kindly let me know if I am missing something, and if there is any way out. If my approach is not correct, I would be glad if you can share few other ideas.
I think it's related to the git configuration on your master (or node)
This solution should work to fix your problem:
Jenkins giving error while cloning from gitHub
#Dr.Bokko is correct...and I should thank him for guiding in the right direction. I am trying to give the complete answer. There are three factors based upon which we can do the setup of GIT with JENKINS.
1st Factor: To access GIT repository, if it is a public repository, then user credentials would not be required. But for access restricted GIT repositories, we need to make sure that proper credentials are passed. Git and Git Client plugins need to be installed for Jenkins to understand GIT operations.
2nd Factor: Before running the script, add a build step and export all the libraries needed as a part of the shell script.
3rd Factor: Finally check the System Configuration in Manage Jenkins section and check the environment variables which are considered by Jenkins. If they are not appropriate, then go to the nodes management link, and all the environment variables as KEY-VALUE pairs.
Hopefully, these steps mentioned above would solve the problem.
The following error appears in your stacktrace:
Cannot run program "git": error=2, No such file or directory
What that means is that the git executable is either not installed or not in the command path of the process running ANT.
It's not entirely clear why you're calling GIT from ANT. Normally Jenkins would perform the checkout of the code first (using GIT) and then call ANT. I would highly recommend investigating this alternative workflow, which might require the installation of a GIT plugin for Jenkins (can't remember if this is a default plugin or not).

Eclipse java build slower after moving project to GIT

I'm new to GIT and recently moved over one of my eclipse java projects.
I noticed a significant delay in the auto build of my project after moving it to GIT. Seems to be some GIT update that happens on every save.
"Updating GIT status for repository GIT"
I'd appreciate any insights.
Eclipse version: Luna RC3 Release (4.4.0RC3)
I'm not sure if this is the culprit but almost every time in the last couple of Eclipse releases I have had issues with the Remote System Explorer which often for some reason gets called when you have source control plugins or aspectj on a project.
For a git project on Luna I turned it off by following:
"Remote System Explorer Operation" causing freeze for couple of seconds
Yes the answer is for a different problem but again I have found the Remote System Explorer to be the culprit (or maybe indirectly I don't know for sure but I do know when I turn it off things get faster). There is also some git specific answers to that referenced SO question but I found I had to turn RSE completely off.

how to auto synchronize sources from svn and auto execute execute maven build and send email in case of failure

I have a windows machine were I want to auto synchronize sources from svn either in eclipse or tortoise svn and when sync is done then I want to run maven build automatically and send email in case of failure..Please note this machine will not be used for development so no question of svn conflict.
Please let me know any hint in this regard,how can i solve the problem ? do we have any utility in maven which can do this for me?
You can use any continues Integration server for this.
Jenkin CI server details check here.
For auto-synchronization:
Open Synchronization view(Windows->Show View->Other and type Synchronize). Open the menu of this view by clicking down arrow button(Right most button in the view) then you will get
Click on schedule and provide required info

Categories

Resources