Connection between 2 Jenkins server with out using master slave concepts - jenkins

How to establish connection between Jenkins jobs hosted on different server with out using master slave concept
I need to send the parameters from one Jenkins server to another both were hosted in different server;
and i need to trigger a down stream project in another Jenkins server

You can use Parameterized remote trigger plugin: https://wiki.jenkins.io/display/JENKINS/Parameterized+Remote+Trigger+Plugin
There are two parts to use this plugin-
Configuration - Go to Manage Jenkins -> Configure System -> Parameterized Remote Trigger Configuration
fill the parameters as appropriate and check the connection using 'validate address' button. If it is validated successfully you are good to go.
Calling a job on remote server - In your job you can add a build step "trigger remote parameterized job".
Fill in the remote server name, poll interval, job name and other parameters.
Now when you will run your job, it will trigger the job on remote server and will check for status on the interval given in poll interval option.

Related

Is it possible to trigger a job from Jenkins by parsing/receiving an event from Git/Gerrit Replica/Slave server?

I would like to connect my Jenkins to the Git/Gerrit replica/slave server. I want my Jenkins server to start building job once a commit is merged in the replica server. It is possible with Git/Gerrit Main server, but not sure whether this can be achieved via Gerrit replica or slave server.
I don't see any problem, I think you just need to create an additional Gerrit server at:
Jenkins > Manage Jenkins > Gerrit Trigger > Add New Server
And point to the replica/slave server at "Hostname" and "Frontend URL" fields.

How to trigger on-premise jenkins job from VSTS using service hook

My source code is present in VSTS(cloud) and Jenkins job in the on-premise server(don't have public IP). I would like to implement Continuous integration.
I have a one local build agent. VSTS build definition able to trigger Jenkins job using the agent. But I don't want to create a job. So how to trigger Jenkins job using service hooks.
It's impossible to add local jenkins server to service hook.
Since the local jenkins server (such as http://localhost:8080 or http://{ip}:8080) can not accessed by public network, VSTS can not access to your local jenkins neither. You should make sure the jenkin url is reachable for public network if you need to use service hook.
And if you want to trigger Jenkins build for the event that VSTS build completed, you can add Jenkins Queue Job task the the end of the VSTS build. Detail configuration for this task as below:
Add jenkins service endpoint by clicking the New button -> Input jenkin URL, username and password -> not necessary to verify connection since the public network can't reached -> OK -> input jenkin job name.
Now when the VSTS build pervious tasks are succeed, then jenkins job is triggered.
Note: You should queue the VSTS build by private agent on the same machine where jenkins server installed.

Jenkins - Build Steps

I am currently writing a Jenkins job to connect to different sql servers to check if all the application servers are up and running.
What I want to achieve:
Connect to QA SQL Server, run the query to verify server status.
Parse the Jenkins log and If any of the servers is down, send a mail to destination1#abc.com with the server name and server id.
Connect to Parallel SQL Server, run the query to verify server status.
Parse the Jenkins log and If any of the servers is down, send a mail to destination2#abc.com with the server name and server id.
Challenge I am facing:
I have used 2 build steps (Windows batch command) i.e. one for parallel and one for QA. But, if the first one fails, Jenkins doesn't execute the second one.
Can someone please suggest how this can be achieved?
The classic solution would be to write the second build step as a Post-Build step, using the JENKINS Post build task
That post build step would be executed even if the first build step fails.
But the more modern and logical solution would be to execute them in their own job, using the JENKINS Multijob Plugin, or even Jenkins pipelines, as shown in "Jobs in parallel".

Communicate between Jenkins server without setting up master slave relation

I would like to set up jenkins server that would run test scripts based on successful build deployments on other Jenkins servers. for example, if the QA jenkins server is named JQA1OnMachine1 and i have three others that are named
J2OnMachine2, J3OnMachine3, J4OnMachine4 (different jenkins server on different boxes) can the JQA1OnMachine1 (QA jenkis) poll the others at regular interval to see if a build was deployed successfully? if so can anyone tell me how?
Jenkins master slave along with Jenkins Pipeline Plugin would be one of the better ways to implement this however, since you don't want to use that approach you can explore PSTools to remotely capture processes or files on different server.
Your builds may update a file on the build server post completion of the build and your QA machine can run script with PSTools to monitor and trigger the QA testing based on the file content

Is there any way to integrate Bitbucket on cloud and Jenkins On premise

I am trying to integrate Bitbucket on cloud and Jenkins on premise, but once I enter the IP of my local Jenkins in Bitbucket cloud it show error URL not valid.
Is there a way to solve this, or do I need to buy Jenkins cloud license?
Your local Jenkins server is not seen by a cloud Bitbucket server because it is an internal server.
You can solve it in one of those alternatives:
Ask your system administrator to expose your Jenkins server with a global IP address along with the Jenkins port (e.g. 8080) so the Bitbucket server will be able to access it. This is not totally secure due.
Activate the Jenkins job that pulls from the remote BitBucket server on time internal - in the Job 'Build Triggers' section check the 'Poll SCM' checkbox and set the cron setting (for example: 'H/15 * * * *' for building every 15 minutes. Notice that it will not build if there were no code changes)

Resources