jenkins,puppet,rhel , puppet detect if a file changed but don't change it


puppet detect if a file changed but don't change it

Question:

Tag: jenkins,puppet,rhel

I want to manage the config.xml file of the jenkins-service with puppet. The problem is that if Puppet changes the config.xml file and than restarts the jenkins service, the config.xml file gets overwritten by the currently loaded configuration of jenkins and the changes made by puppet are lost.

That's what i have now:

file { '/var/lib/jenkins/config.xml':
  source    => 'puppet:///modules/jenkins/config.xml',
  owner     => jenkins,
  group     => jenkins,
  mode      => '0644'
}

service { 'jenkins':
  ensure    => running,
  enable    => true,
  subscribe => File['/var/lib/jenkins/config.xml']
}

My approach is to stop the jenkins service, than copy the config.xml and start the service again... naturally the service should not be stopped and started again every time puppet runs but only if the config.xml changed. I don't know how to do this with puppet and even if it is possible. Any ideas?

Any help would be much appreciated


Answer:

This is sort of a painful thing to handle with puppet, but one way to do it is to detect the change to a staging file and then use an exec to sequence the file changes:

file { '/some/staging/path/config.xml':
  source    => 'puppet:///modules/jenkins/config.xml',
  owner     => jenkins,
  group     => jenkins,
  mode      => '0644',
  notify => Exec['Update Jenkins Config']
}

exec { 'Update Jenkins Config':
  command     => '/sbin/service jenkins stop && /bin/cp /some/staging/path/config.xml /var/lib/jenkins/config.xml && /sbin/service jenkins start',
  refreshonly => true
}

Related:


Puppetelabs Vagrant Box password not working


vagrant,puppet
I'm trying to bring up a Puppetlabs vagrant box and the password is not working. Tried 'vagrant' and 'puppet'. Anyone get these working?

determine if it is jenkins environment inside gradle


jenkins,gradle,jenkins-plugins,build.gradle
I am just wondering is it possible that I can tell whether I am in a Jenkins environment inside gradle? I just want to do something like if (jenkins){ //do something }else{ //do other } ...

Am I using puppet contain correctly?


dependencies,puppet,contain
I am trying to create a dependancy relationship so that the phpwebserver profile is run before the silex_api profile. role: class roles::dev{ include profiles::phpwebserver include profiles::silex_api Class ['profiles::phpwebserver'] -> Class ['profiles::silex_api'] } silex_api profile: class profiles::silex_api{ class { '::silex' : package_version => '1.6.2', } class {'::composer' : command_name => 'composer.phar',...

Install gradle on Centos


jenkins,gradle
I'm trying to install gradle for building android app with the help of Jenkins. But I'm not able to find the link to download gradle for Centos. I tried to use binaries from https://gradle.org/downloads/, but when I unzipped I got gradle.bat file inside bin directory which tells me that this...

Triggering Jenkins to run application tests when GitHub PR is created


git,jenkins,continuous-integration,ansible,continuous-deployment
I am a noob to Jenkins, and I have a Jenkins server that runs an ansible playbook to deploy the app. I would like to be able to have Jenkins run an ansible playbook which runs application python tests when a GitHub pull request is opened. I would then like...

Get the Git Working Branch in Gradle on Jenkins


git,jenkins,gradle
I want to have the current Git branch in the Version name of my Android app. I built in this snippet from here into my build.gradle: def getWorkingBranch() { // Triple double-quotes for the breaklines def workingBranch = """git --git-dir=${rootDir}/git --work-tree=${rootDir}/.. rev-parse --abbrev-ref HEAD""".execute().text.trim() print "Working branch: " + workingBranch...

Downgrade Jenkins


jenkins,downgrade
I updated Jenkins some days ago. But in current Jenkins version, there are some annoying bugs. Is it possible, to downgrade the version of Jenkins and when it's possible, how is it possible?

How can I run the Jenkins jobs through terminal?


jenkins,terminal
I heard an version that webhooks could be used for this. Please help)

Display artifact in Jenkins Build description


plugins,jenkins
I would like to automatically display a artifact as part of the build description. Now I can do this by manually editing the build description but that would mean I have to do this for every build. Is there a way to automate this? This is what I would like...

create email list of all users


groovy,jenkins,jenkins-scriptler
On occasion I need to email all Jenkins users, for example warning them Jenkins will be offline for maintenance. The script below gives me email addresses for all people that Jenkins knows about, but it includes people that don’t have accounts, these are people that have committed changes that triggered...

Excluding jobs that haven't run recently from a view in Jenkins


jenkins
Is it possible in Jenkins to exclude jobs from a view if they have not run recently? I would like our default view to exclude jobs that have not run in the past month, because we don't need to see jobs from parts of the product that are not under...

Saving docker container image


jenkins,docker
I created a new docker container using jenkings image This is the command I ran docker run -p 8080:8080 -v /var/jenkins_home jenkins I created a few jobs on the jenkins instance and commited the image docker commit 7b903d061654 test When I run the image I created using the command (below)...

How to dynamically create an environment variable?


powershell,puppet
I am using powershell script to set some environment variable-- $env:FACTER_Variable_Name = $Variable_Value FACTER is for using these in the puppet scripts. My problem is - the variable name and variable value both are dynamic and getting read from a text file. I am trying to use $env:FACTER_$Variable_Name = $Variable_Value...

Openshift - trigger Jenkins build on git push


jenkins,openshift
I work with Openshift now and I have a problem. I created an application server with Jenkins and when I push to the master branch of the git repository the Jenkins build is triggered automatically. The point is that the build isn't triggered when I push to another branch (not...

Implementing security for users in jenkins


jenkins,jenkins-plugins
I am after a better solution for security in Jenkins. After my play around this space, my current solution is to implement the 'Project-based Matrix Authorization Strategy'. I was previously considering running Jenkins behind Apache and control security through Apache. But during my trial with matrix based security, I was...

SBT is wasting lots of disk space for dependencies each build


jenkins,sbt,playframework-2.4
We have a Playframework 2.4 (with SBT 0.13.8) project which we build on a Jenkins. Today, the Jenkins stopped working because his $JENKINS_HOME run full. I analyzed which tool was wasting the disk space: SBT. There is a folder located at .sbt/0.13/dependency/module/dynamic that contains quadrillions of subfolders. Each of these...

How to block a Jenkins job from running at certain times


jenkins,jenkins-plugins
I have a Jenkins job which restarts our small in-house production system. It is fully automated, so when we check-in code changes, we run tests and other verification steps and finally automatically deploy the new version. It is usually not a problem restarting the system as it will be back...

Avoid large log Jenkins file (and stop build if needed)


jenkins,jenkins-plugins,diskspace
We are using Jenkins (on Linux) to manage our Maven builds. Our users can create their own job and sometimes (3 or 4 times per year), they are doing a mistake and the job generates a large log file (79 GB the last time...). I had a look to existing...

Jenkins Flexible Publish plugin if else condition


if-statement,jenkins,jenkins-plugins
I am using the flexible publish plugin for jenkins and found it very useful. My goal is to pass a set of predefined parameters from a job to trigger another downstream job. The downstream job performs an action based on the string match evaluation. But if i dont pass the...

Wrap resources inside custom class and invoke class?


nginx,puppet
I am using Puppet 3.0. I tried to use the existing NGINX module but encountered one issue which no answer seems to exist. I have moved to implementing NGINX module myself which handles my exact requirements. Each package/service/file resource works as expected and now I am moving the code out...

Jenkins does not find my git repository in Visual Studio Online


git,jenkins,visual-studio-online
I have a Visual Studio Online project working with Git. Everything works fine from inside Visual Studio. I'm trying then to configure a Jenkins job that gets the code from this project, but without success. Although the URL and the credentials are correct, Jenkins gives me this error on the...

how to identify user who created a specific job on jenkins?


jenkins,jobs
Problem In jenkins, I cannot find the job creator for a specific task. Tries I tried looking in the changes log, do not display creation. Looked up in the user profiles and there is no such properties. Been fooling aroung for a while now trying to find it. Also most...

How to access jenkins parent job build id in a MultiJob?


maven,jenkins
I have a requirement to trigger Automation Suite in multiple phases and summarize test results in a single test summary report. I configured a Jenkins Multi Job to trigger my automation suite, which is divided in to multiple chunks say suite#1, suite#2, suite#3, suite#4 (each suite is a maven job)...

Upgrade SonarQube issues


service,jenkins,webserver,sonarqube,sonarqube-5.0
I'm having issues installing my instance of SonarQube 4.4 to 5.1. The instructions say to stop the SonarQube server, match up a couple files (back up DB, copy plugins, etc.), and then restart the sonar server for the updated version. My problem is I'm not sure how to start/stop the...

Single Jenkins instance using multiple Sonar instances


java,jenkins,sonarqube
Is it possible to configure Jenkins to use multiple Sonar instances? Currently we are using one Sonar instance for legacy projects (Java 6) and a new Sonar instance for Java 8...

How to display all keep forever build number using Jenkins REST API for a specific job?


jenkins
I read the following post which does what I want for all jobs (and I made it works) List all keep-forever builds in Jenkins? here is what I have now : http://jenkinsmediaprocessor:7880/api/xml?depth=2&xpath=/hudson/job/build[keepLog=%22true%22]/url&wrapper=forever But I only want to display a specific task. However I don't know where to set the job...

using classes in jenkins job dsl


groovy,jenkins,jenkins-job-dsl
Hi all I have a problem and I can't seem to figure it out. So I'm creating some helper classes for my dsl to use, but it just does not seem to execute any method within these classes. I have created a job with the following dsl in it: class...

Some of my tests show prepended with junit.framework


java,unit-testing,jenkins,junit,junit4
I have a set of junit tests that run automatically on my build server (Jenkins). I run more than 500 tests. Most of them, in the test results view, show up with the correct package value Example : results for com.test.app.RollingArchiveTest But I have 8 tests that have junit.framework prepended...

Advantage of Jenkins Master/Slave architecture? [on hold]


jenkins
I am reading about the Jenkins Master/Slave architecture and how to configure it from here and as I am going down the page I am wondering why should I do it, what benefit I can achieve through it. I searched similar questions and reached here but still not convinced about...

Vagrant + puppet + docker


mysql,docker,vagrant,puppet
I'm new with this technologies but I want to learn about automation and containers stuff. I read some documentation about this 3 products and I want to know if is possible to automate almost everything in a large environment using this products. Vagrant for deploy VMs (let's say 10 at...

Execute SVN Update in Jenkins - Copy a Folder to Web root Explicitly from SVN as a Build Step


powershell,batch-file,jenkins,jenkins-plugins
I'm new to Jenkins CI.I'm trying to get SVN update (myFolder) inside a job as build steps. I want to explicitly copy some files to web root as I can't have them inside my solution. Build Steps I need to perform. Build Solution Publish Copy myFolder to web root Sync...

Retrieving command line -D options in Java


java,maven,jenkins,jenkins-plugins
I have clean integration-test -DclassId=appas a maven goal in a Jenkins Maven Job. How can I retrieve this in Java using System.getenv();? When I do this I am only seeing null....

Why does `su` not work in Jenkins?


shell,jenkins,su
su doesn't seem to work as intended when run in Jenkins build job script. su username1234 whoami returns jenkins My initial guess is that each line of the Jenkins shell script is a new shell. But doing repeated echo $$ on separate lines shows that's not the case. ...

Find view name from jenkins GUI given the job details


jenkins,jenkins-plugins
I have few hundreds of jenkins jobs all classified into different views based on different projects. So, I already have around 30+ views in Jenkins. My question is, Given a jenkins job name can I find out which View it is classified into.

How to force team members to comment using eclipse plugin or something else


eclipse,jenkins,eclipse-plugin,coding-style,build-automation
Currently, I am working in a new project and it was difficult for me to understand since there is no comment. I wonder if it is possible to force team members(including me) to add more comments. I would like to automate this ject in jenkins later if possible.

Fail Jenkins job when nosetests fail


python,shell,jenkins,continuous-integration
I am managing deployment / CI of a Flask app through Jenkins. I have a build step in the form of an executed shell which runs a shell script in the host that in turns runs nosetests. The Jenkins shell command looks like so: $WORKSPACE/ops/test_integration.sh integration.sh looks like so: SETTINGS_FILE="settings/integration.py"...

how to add template file in rspec-puppet


rspec,puppet
I have below manifests for sudo user, loading template file class sudo { if $::operatingsystemmajrelease < 7 { $variable = $::operatingsystemmajrelease ? { '6' => $::fqdn, } file { '/etc/sudoers' : ensure => present, owner => 'root', group => 'root', mode => '0440', content => template('sudo/sudoers.erb'), } } } Below...

Jenkins execute shell on job's executor during CONFIGURATION time (and access workspace)


java,shell,jenkins,jenkins-plugins
I would like to create a simple Jenkins plugin. Basically it is a custom build step (Builder extension) with a dropdown list. The trick is that I want to fill this dropdown list from the result of a shell script/command executed during configuration time. Here is my method stub. public...

How do I print the current classpath for a Jenkins plugin?


java,jenkins,classpath,classloader
I'm developing a Jenkins plugin but I'm having a few problems which I think might be due to a jar missing in the plugin's classpath even though its in the plugin's WEB-INF/lib directory. Normally I would use the following code in Java to print the classpath but this doesn't seem...

Jenkins continuous deployment error


git,jenkins
I am learning Jenkins CI test & deploy as stated in the excellent tutorial http://code.tutsplus.com/tutorials/setting-up-continuous-integration-continuous-deployment-with-jenkins--cms-21511 at the end of the tutorial, it should handle the deployment of the app... as per the deploy script and the Jenkins project config w ./script/deploy #!/bin/sh ssh [email protected] <<EOF cd ~/hello-jenkins git pull npm...

Build failure due to Sonar plugin


service,jenkins,sonarqube,sonarqube5.1
My build keeps failing on Jenkins because of this error: ERROR: Error during Sonar runner execution org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91) at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) at java.security.AccessController.doPrivileged(Native Method) at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) at...

Booting up Vagrant from Jenkins throws Permission Denied


jenkins,vagrant,jenkins-plugins,vagrant-plugin
I am trying to Boot up Vagrant VM from Jenkins. I gave Vagrantfile path in 'Boot up Vagrant VM'. When the job runs, I get the following error: Failed to iterate on remote directory vagrant_projs [ vagrant ]: Executing command :[vagrant, up] in folder /Users/abc/Desktop/vagrant_projs [vagrant_projs] $ vagrant up [...

Puppet inline template with puppet:// in URL


puppet
In my Puppet module, I have something like this: file {'myfile': ensure => 'file', path => '/whatever/myfile', content => inline_template(file( "puppet:///modules/my_module/templates/${domain}/${::hostname}_myfile.erb", "puppet:///modules/my_module/templates/${domain}/myfile.erb" )) } And my spec looks like: require 'spec_helper' describe 'my_module' do context 'with defaults for all parameters' do it { should compile } end end If try...

unable to get pylint output to populate the violations graph


jenkins,jenkins-plugins
my build steps: cd $WORKSPACE export TERM="linux" . venv/bin/activate pylint --rcfile=pylint.cfg $(find handlers -maxdepth 1 -name "*.py" -print) > pylint.log || exit 0 result of pylint.log: ************* Module handlers C: 1, 0: Missing module docstring (missing-docstring) C: 8, 0: Missing function docstring (missing-docstring) ************* Module handlers.foo C: 1, 0: Black...

Jenkins Console Output Error


jenkins,jenkins-plugins
We've been using Jenkins for a while now, but recently we've added a couple plug-ins to the configuration and our Console Output is not showing in real-time anymore, we just get a big fat Java error! I've removed the offending plug-ins (emotional jenkins and Green Spot) in an attempt to...

Jenkins (cloudbees): remotely trigger build (e.g.via instant message) w/o creating user account in Cloudbees


jenkins,cloudbees
We're using Jenkins (and precisely Cloudbees) for couple years. Well, it works. Not I have new use case when I would like to allow trigger build remotely (w/o user account in Cloudbees). Looks like it's impossible (standard token trigger mechanism requires an account in Cloudbees). The only one way that...

Is it possible to save an adobe pdf file using selenium web driver and one click build Jenkins


java,pdf,selenium,jenkins
Here's my dilemma. I'm creating some automation tests using selenium web driver coding in Java. The main output of the software is to load a PDF in adobe acrobat. I'm also using Jenkins which is why my problem has come about as I wont be able to physically see the...

Using external variable in rspec-puppet test


ruby,rspec,puppet
Have some stuck with using variable in rspec. Here is my params.pp case $::osfamily{ Debian: { $ssh_daemon = "ssh" } Redhat: { $ssh_daemon = "sshd" } In rspec test i need to use variable $ssh_daemon, like this it { should contain_service("${ssh_daemon}").with( :ensure => 'running', :enable => 'true', )} Here is...

multiple similar files on one host from one template in puppet


templates,puppet
all. This seems like something other people would have already answered, but I couldn't find it, so apologies if this is an old question. I want to make multiple files on one host from the same template. These are dnsmasq hosts files for IPs on an internal vs external network....

can't export a variable from execute shell in Jenkins to other project (with using properties file)


bash,shell,jenkins
I have a Jenkins project with one "Execute shell" that executes some bash commands and exports one variable to the env. variables: #!/bin/bash ... TARGET_FULLPATH="blablabla" export TARGET_FULLPATH In addition, I have configured to "Post-build Actions" with: "Trigger parameterized build on other projects" "Current build parameters" "Predefined parameters" -> FULLPATH=$TARGET_FULLPATH But,...