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

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.

Related

Jenkins SSH Agent Plugin shows empty drop down in Jenkins Job

I am using SSH Agent Plugin version 1.17 with Jenkins version 2.190.3
When I create credentials using
Jenkins -> Credentials -> System -> Global credentials (unrestricted) -> Add Credentials
But when I create jenkins job type Freestyle project, I don't see credentials in ssh agent drop down.
Please advise what I am missing
Ref:
https://wiki.jenkins.io/display/JENKINS/SSH+Agent+Plugin
https://support.cloudbees.com/hc/en-us/articles/360029470091-How-to-use-the-SSH-Agent-Plugin
Jenkins plugin ssh-agent showing "ERROR: Failed to run ssh-add"
Update:
Issue is open for credentials (username/password) https://issues.jenkins-ci.org/browse/JENKINS-59807
but good thing is that it works with private key :)
You have to select Kind as SSH Username with private key to be able to specific use credentials in ssh agent:

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

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.

SSH errors with Jenkins git plugin

There are lots of question on here about Permission denied (publickey) errors when using the Jenkins git plugin.
Can someone explain the authentication flow this plugin uses to check out a repository? I can't find a good description on the plugin page.
I want to just SSH into the build slave, checkout the repository there, then run my job, but clearly that is not how it works.
I guess I could add my credentials to the jenkins master, but I dont want any code there. I want it on my build slave.
Issue has nothing to do with git really. As their documentation states, it relies on git runtime which in its turn relies on system environment when it comes to secure connections. Ssh requires client to have valid key to connect and fails to that message if client does not provide one. Without any additional actions, key is not injected into environment, so client could not provide any valid key.
What you actually can use is ssh agent plugin. That allows to add key to ssh-agent on slave that will be catched up by git.

Jenkins: Use credentials from Credentials Plugin in the M2 Release Plugin

I want to use the M2 Relase Plugin to release artifacts on a Jenkins server. The access to and checkout of the sources from Subversion is done with help of the Credentials Plugin. For tagging and committing the changes during the maven release:prepare phase I need (in my case) the same credentials.
Is there a way to convince the M2 Release Plugin to take credentials from the Credentials Plugin?
Note: I don’t want to insert the credentials manually in the SCM login/password fields and I don’t want to store the credentials in an extra settings.xml file on the server as often suggested.
I have implemented the following solution, where I do not have to insert the credentials manually again, but where the credentials are stored in a temporary settings.xml file on the file system during the build.
With help of the Config File Provider Plugin I have created an empty settings.xml and used the stored credentials as server settings. The server id I have filled with the hostname from the scm url (see answer to Externalising SCM credentials with Maven). In the Build Environment section of the Jenkins job configuration I have enabled Provide Configuration Files, selected the self created settings.xml, assigned a Variable and used this variable in Release goals and options with -s $variable (like in Running the Maven Release Plugin with Jenkins).

Jenkins 0 files published after build

I have a Jenkins server setup with two jobs
first job polls the develop branch and builds the project on the jenkins server. i then have another job that polls the production branch this builds this branch on another jenkins slave which is the staging server. This job is configured so that on a successful build it should publish the artefacts over ssh to the production server.
All the SSh keys are setup and the staging server connects to production server but 0 files are transferred
using GIT_SSH to set credentials Bitbucket Repo
using .gitcredentials to set credentials
Checking out Revision 89874cc01a9f669df69817b1049b1ab98ecb19d3 (origin/Production)
SSH: Connecting from host [nginx-php-fastcgi]
SSH: Connecting with configuration [AmazonAWS] ...
SSH: Disconnecting configuration [AmazonAWS] ...
SSH: Transferred 0 file(s)
Finished: SUCCESS
I checked the staging workspace and files are being built there, just not sent to the prod server. Any suggestions??
i have also tried a different remove prefix as suggested bellow and here Jenkins transferring 0 files using publish over SSH plugin
You should remove /* from the Remove prefix line
Edit:
Your Source files cannot be outside of the job's workspace. If your files are in the root of workspace, just set it to * to transfer all workspace files, or **/* to include subdirectories. Else specify a pattern relative to ${WORKSPACE}.
Even adding a leading / will not escape that, as all it does is append that to workspace, in your case it becomes ${WORKSPACE}/var/www/workspace/opms-staging-server. Even using parent directory ../ will not work. This is for security concerns, else a job configurer could transfer private files off the Jenkins server.
If you need to get files from another job, you need to use Copy Artifacts build step. Tell me if that's your case, and I will explain further.

Resources