Jenkins user and group removed automatically - jenkins

I installed Jenkins 1.531.1.1 on CentOS 5.5 by executing the below mentioned commands:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
I changed the JENKINS_HOME variable in the /etc/sysconfig/jenkins file to something other than /var/lib/jenkins. I changed the default port on which jenkins runs from 8080 to 9999. I also generated the ssh keys needed to pull code from github.
Unfortunately, when I try to define the github repository url in a Jenkins job, it failed to authenticate. When I checked grep jenkins /etc/passwd, the jenkins user was no longer there. I did the whole process twice and the user seems to be getting removed. Any pointers would be helpful!

The deployment team had set up a script to automatically delete any new users created just for maintenance purposes. The fact that it happened across multiple CentOS servers actually triggered me to ask this question.

Related

Jenkins-X with BitBucket cloud

I've installed Jenkins X on EKS using instructions from https://github.com/jenkins-x/jx-docs/blob/master/content/developing/git.md so that I can use BitBucket with Jira.
jx install --no-default-environments
jx create git server bitbucketcloud -n BitBucket https://bitbucket.org
jx create git token -n BitBucket myusername
When I went to create an environment using
jx create env staging --git-provider-url=https://bitbucket.org
My account is linked to my company team, but the command only gave me an Organisation choice of my username. Continuing, I got a 401 error and could not continue.
Is this supported? I have reinstalled Jenkins-X a few times previously and got it working with GitHub for environments plus BitBucket for code repositories.
I've noticed as well that if I want to create a repository in my Organisation (Team), I must also supply a Project. Is this going to be a problem?
I'd much prefer to do everything in BitBucket, but I may have to go with GitHub if it plays much better with Jenkins X.
Thanks
My understanding is that you want to use a Git Provider other then the default gitea. If you want to do it at the time of jx's first installation, all you need to do is passing all parameters you need directly to jx install [args] command.
Here is a sample which contains enough arguments to make your installation fully working onto your cluster. Be sure to use (or reuse) the ingress in place, if already provisioned by your vendor.
jx install \
--provider <your-provider> \
--git-provider-kind bitbucketcloud \
--git-provider-url https://bitbucket.org \
--default-environment-prefix <your-prefix> \
--git-username <your-username> \
--environment-git-owner <your-organisation> \
--git-api-token <your-api-token> \
--git-private \
--no-tiller \
--verbose \
--log-level debug
It follows command's specification:
https://jenkins-x.io/commands/jx_install/
When it comes to BitBucket' project doubt, the "project" concept is something that strictly concerns Bitbucket, i.e. something you don't have on other git providers. That being said, jx doesn't provide BitBucket with any project specification at the time I'm writing, so that BitBucket default behavior in such cases, is that the repository will be created into the oldest Project you've defined.
Anyway repositories can be freely moved across different projects in your account.

Jenkins re-run setup wizard

Just installed latest Jenkins on Windows server.
Changed it to run as a service and my login no longer works. No problems, disable security for now.
But found out all my plug-ins are missing.
How can I have it rerun the setup wizard?
As seen in issue 310, you need on the server side to remove:
/usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
/usr/share/jenkins/ref/jenkins.install.InstallUtil.lastExecVersion
(Search those files on your Windows Jenkins installation folder, to adapt those paths accordingly)
And you would relaunch Jenkins with -Djenkins.install.runSetupWizard=true
I installed Jenkins through apt and my solution was a little different.
For Jenkins v2.140 I had to edit /var/lib/jenkins/config.xml and change the following line:
<installStateName>NEW</installStateName>
to
<installStateName>RUNNING</installStateName>
then restart Jenkins:
sudo service jenkins restart
Here is everything above in a script:
#! /bin/bash
sudo sed -i 's#<installStateName>NEW.*#<installStateName>RUNNING<\/installStateName>#g' /var/lib/jenkins/config.xml
sudo service jenkins restart
Please note you will have to install all plugins and create users manually. I used the Jenkins CLI

Jenkins, Kiln and Mercurial: abort: http authorization required for [repository]

I've upgraded the OS and the Jenkins that was running on it from Windows XP and an ancient version of Jenkins (installed in 2012). So now I'm on Windows 7 and Jenkins 2.19.1 (the latest at time of writing). Other than that, the only different is that I do not have a jenkins user, and it's running as a service instead of locally on the desktop.
I need to update a repository that is outside my Jenkins workspace. Let's call is C:\Repos\Operations. Doing an hg pull -u in a windows batch command and I get this:
C:\Repos\Operations>hg pull --debug -u
using https://xxx.kilnhg.com/Code/Repositories/Operations
sending capabilities command
xxx.kilnhg.com certificate successfully verified
abort: http authorization required for https://xxx.kilnhg.com/Code/Repositories/Operations
It works fine if I do it in the cmd.exe. I've been searching for hours for an answer. Using hg showconfig --debug the only difference between doing it in the cmd and having hg showconfig --debug in the jenkins windows batch command is the following 2 lines:
read config from: C:\Windows\system32\config\systemprofile\mercurial.ini
read config from: C:\Windows\system32\config\systemprofile\.hgrc
But those files do not exist on my system. So, in theory, it should be reading everything from the same settings location, but it's not.
Does someone have any idea?
Thanks!
Can't comment yet, so this goes under 'Answer': per your comment it does not find the correct '.hgrc' file. Have you tried providing the username/password in the batch command, like here Mercurial (HG) pull parameters: username and password ?

OpenShift Cloud Computing: Advanced installation

I want to install OpenShift using the advanced installation - method on Centos7 (EC2). But first I need to know some issues:
URL of tutorial: https://docs.openshift.com/enterprise/3.0/admin_guide/install/advanced_install.html#installing-ansible
First I need to configure the prerequisitions on the master and its 2 nodes (https://docs.openshift.org/latest/install_config/install/prerequisites.html).
When that's done the advanced installation will start.
1) Do I have to install ansible on the master only and running the installer at the end or do I need to install anything on the node (except docker)?
2) Which steps do I have to follow here: https://github.com/openshift/openshift-ansible or just download the repo and following the tutorial.
3) Is there something necessary what needs to be installed or configured which is not cited?
You are correct to start with the prerequisite steps outlined in the origin documentation.
In particular,
Ensure that you've completed host preparation steps. These steps include packages that must be installed on every system.
Ensure that you've configured host access. The ansible installer uses ssh key authentication by default so you must be able to login to each system (including the master) from the master with ssh key authentication.
Ensure that the output of hostname -f outputs the correct hostname of each system.
Once you've finished with the prerequisite steps, you will move on to the advanced installation section. Steps for installing ansible and creating an ansible host inventory can be found here. You only need to install ansible on the master. Once you've installed ansible and created a host inventory you can run the ansible playbook to begin the installation.
Afterwards, you can verify the installation and then complete follow up items such as configuring authentication, creating a router and creating a docker registry.
If you encounter any problems with the advanced installer, create an issue with the openshift-ansible project.

Jenkins' /etc/default/jenkins not update safe?

I installed Jenkins using apt-get install jenkins. Then I made some changes in /etc/default/jenkins (which is, as far as I know, the only way to change the Jenkins system user etc.). Now I found out that this file becomes reverted with every update (using apt-get update).
In addition I changed the owner of some files of the jenkins installation (e.g. /var/lib/jenkins, /var/log/jenkins and some others) because I changed the user under which jenkins should run. Also these permission changes are reverted after every update.
There are two solutions I could think about, both not really "nice" and clean:
Install and run the jenkins.war manually without any package management
Write a DPKG-Post-Install-Trigger that fixes the problems after every update
Does anyone have a cleaner solution for that?
Two answers occur to me
1) Download the source package that apt-get uses and modify the users, permissions etc to suit your local use. Rebuild the package and either install it from cli with dpkg -i or make your own repository for local use.
or
2) Use a tool like puppet to manage the package install and then apply the changes required locally afterwards. The puppet "package/file/service" pattern explained in various places including here https://docs.puppetlabs.com/puppet_core_types_cheatsheet.pdf shows how to do the puppet manifests for this

Resources