So the way I have this setup is:
Jenkins Polls for changes on repo
Jenkins Initiates Ant
Jenkins uses SSH plugin to run a script on a remove server (to run a git pull)
The problem is that if Ant fails, Jenkins still moves on to step 3 and processes the script.
How do I make Jenkins just stop everything after step 2? Or is there a better way of doing my process?
I think what I really needed was Publish Over SSH instead. This enables you to include it in the Post Build Options.
Related
The setup is as follows:
Step 1: I am developing on a windows 10 machine
Step 2: Building artifacts with Maven (using powershell)
Step 3: Go to (semi-local) Jenkins which is running in a Linux VM on my machine & trigger a Jenkins job that syncs and deploys my artifacts to the application server running on the VM.
Q: Is it possible to automate/merge Steps 2 and 3 in this scenario?
(Building and deploying each takes several minutes)
Yes, you can.
Create a custom goal which will trigger the Jenkins with an URL.
But, ideally, I would suggest to build and deploy using Jenkins by fetching the code from the repository when there is a change
Yes you can.
I suggest you use webhooks (github, gitlab, bitbucket,...)
Steps will be :
Install some plugin in your jenkins in order to expose a job as public url.
Configure your webhook in git provider adding url created in step 1
Push some changes to your code
Your git provider detect this event and execute the url created in step 1
Your jenkins job is launched. Put your mvn commands and deploy commands in this job. I suggest you use jenkins pipeline job.
Contact me if you need some help.
Post step by step :
https://jrichardsz.github.io/devops/devops-with-git-and-jenkins-using-webhooks
I recently created an automated process to run multi-step Maven builds for my organization. They now are looking to have the entire process automated using Jenkins. I have been able to successfully create branches, builds, change versions, etc., using Maven commands but I am having difficulty committing the version changes (1.0.1-Snapshot to 1.0.1-E1 for example) with Jenkins. I have tried using basic commands like:
SVN commit "Comments"
However, Jenkins does not seem to know what to do with these command lines in the "Execute Windows Batch File" Post Build option. I simply receive build failures caused by the batch file for "unknown reasons." I see the help desk I am working with has installed the Subversion plugin, but perhaps something else is missing. I know that when I use the command prompt locally I need to use something like this:
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"
/command:commit /path: /url:
However, Jenkins is hosted by a third party and I do not have direct access to the servers so I would not be able to implement that kind of path data. So I am now looking to see if I can run this, somehow, purely through Jenkins as my client requests.
Anyone have any success with SVN Commit to update version changes through Jenkins?
Thanks!
-Cameron
Why did you decide to run TortoiseProc via Jenkins? TortoiseProc is not the right tool for this task, use svn.exe client.
TortoiseProc can be used for TortoiseSVN's GUI automation, but this case is completely different to running Jenkins.
I'm using ansible to deploy and install builds on to my servers, but I have to feed Ansible with build name, to grab it and deploy. I would like to close this loop since I have to deploy the builds thrice a day. Is there a tool to do this so that everytime it sees a new build it will automatically invoke the ansible playbook. Or should I go ahead and write my own tool to do this. I'm open to suggestions.
Ansible itself can't do this for you.
But actually there are zillion of other options available: from simple crontab script to complete CI/CD tools such as Jenkins.
I have used jenkins for a while and I can confirm that Jenkins can do that for you.
Once a commit is done, can it compile your solution and deploy to required environment
I have TeamCity installed on centos. I have only one Linux BuildAgent for now. My build configuration execute a maven script and using ant upload WAR artifact to Windows Server on FTP. After this step i have to execute BAT file on remote Windows Server. I read that i can do this using psexec/RemCom, but i can't understand how i can do this in TeamCity? Build Step or different Build Configuration should contain steps to execute psexec/RemCom or i can insert Build Step into existed Build Configuration?
Single build configuration could potentially consists of multiple build steps. Think of them as a actions you would like to do. So I suppose that right now you have a maven step in your build configuration. I would suggest you to add Command Line step, where you can do what ever you want -- it's like bash/batch script. You can put script contents directly to the build step, or you can write script and execute it.
But as you mentioned that you have CentOS, it could be you have to do extra configuration on the build agent for PsExec to be available.
I want to write a shellscript, in which it git pulls the remote repository.
and if the local repository is not up-to-date then trigger the build of hudson job.
In further scenario :
1) where to link up this shellscript (my shellscript ".sh" file) in hudson. so that it gets executed periodically before build.
Is there a way in configure Job :
2) Adding "execute shell" build step in hudson? and writing my shellscript over here.
Please specify me with shellscript code too.
From what you describe you should just use Jenkins' Git plugin. Is there something you are trying to do that isn't covered by it?