Reload configuration with Ansible, when SCM Sync configuration plugin is used - jenkins

I'm installing Jenkins 2, with all plugins using Ansible and I wan't to use SCM Sync configuration plugin [1] for managing Jenkins configuration. Is there a way to do SCM Sync configuration plugin reload [2] externally? I have tried Ansible URI module and also tried to use wget, problem seems to be that it does not authenticate.
[1] https://wiki.jenkins-ci.org/display/JENKINS/SCM+Sync+configuration+plugin
[2] http://password:username#jenkins_url/plugin/scm-sync-configuration/reloadAllFilesFromScm

Try below steps,
Install Jenkins and configure SCM sync plugin to include all the necessary Jenkins jobs/configuration that include scm sync plugin configuration too.
When you are trying to extract in new instance/reload use "git archive ---" command in ansible playbook/role to extract and restart jenkins.
Before step 2 make sure git config file and SSH Keys
is configured for Jenkins user to Git account.

Related

adding remote hosts to jenkins programming

In Jenkins there is a general SSH Plugin. that I plan to use now that The "Publish over SSH" is the old plugin and is deprecated."
How would I go about adding hundreds of remote hosts to a new Jenkins I am building using this plugin without manually adding the list of servers to jenkins
https://plugins.jenkins.io/ssh/

Jenkins Options missing while entering a private key; "from a file on jenkins master" and "From the Jenkins master ~/.ssh"

I have set up a new Jenkins Server and copied the Jobs and plugins from the old Jenkins Server, but stragely there are 2 Options missing while entering a private key for the global User/Account. The Options are "from a file on jenkins master" and "From the Jenkins master ~/.ssh".
I doubt that there is some plugin missing, as I have copied all the plugins from old Server. Any clue will be helpful.
These options was removed due to security reasons since version 1.14 of SSH Credentials Plugin:
SSH Credentials Plugin no longer supports SSH credentials from files on the Jenkins master file system, neither user-specified file paths nor ~/.ssh. Existing SSH credentials of these kinds are migrated to "directly entered" SSH credentials.

How to use ssh jenkins plugin in pipeline to remotely execute in the remote machine

I used ssh plugin in Jenkins Job to ssh into a remote machine and run commands in that machine. I am trying to use the pipeline for Jenkins and I cannot find the script for the plugin.
It looks like this is not supported.
ssh-plugin is not listed in the pipeline compatibility list.
There is no reference to any workflow plugin inside the ssh-plugin POM, like in e.g. the ssh-agent plugins POM.
The last release of ssh-plugin is Jan 8, 2014.
I'd conclude this plugin is abandoned. However there is some commit activity. Consider writing an issue.

Building Jenkins Config using SCM SYNC plugin

I am using bitbucket to host my Jenkins config file. I have one question though. Does Jenkins pull latest config file everytime Jenkin is restarted from bitbucket or will it pull it from local stored configuration and use SCM for only version control?
It works Viceversa. But
By default, SCM Sync plugin will check-in your local Jenkins changes to Bitbucket and keep it in sync with your local system (backup your changes)
if you want to retrieve/get changes from bitbucket you need to do manually "Jenkins->configuration->SCM Sync configuration->Reload config from SCM" manually then only you get backup from bitbucket account otherwise it's going to step 1 as it will keep your files safe in bit bucket

Jenkins Remote Deployments

We're trying to setup Jenkins, but we are having a couple issues.
We have a "Jenkins Server" (Master) and have connected it to Fisheye. Jenkins is able to get the Git repo and run the tests.
Is there some kind of built in process for Jenkins to give it capabilites to SSH into a server and run commands like "git pull origin master" ?
Yes there is ssh capabilities in Jenkins. You can add a build step for either running SSH or sending files over SSH (you have to define target server in config). Theres also a post build plugin for sending artifacts over ssh which can be used to also execute remote commands.
I'd recommend a book by John Smart which covers Jenkins setup. Its at http://www.wakaleo.com/books/jenkins-the-definitive-guide
I think you want the SSH Plugin for Jenkins. This will let you define SSH servers in your global configuration, and then define commands to be run before and after the build.

Resources