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


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


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


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

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...

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

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)...

Downgrade Jenkins

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?

Wrap resources inside custom class and invoke class?

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...

unable to get pylint output to populate the violations graph

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 C: 1, 0: Black...

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

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...

Implementing security for users in jenkins

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...

Find view name from jenkins GUI given the job details

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.

Jenkins does not find my git repository in 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...

Get the Git Working Branch in Gradle on Jenkins

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...

create email list of all users

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...

SBT is wasting lots of disk space for dependencies each build

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...

Fail Jenkins job when nosetests fail

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/ looks like so: SETTINGS_FILE="settings/"...

Puppetelabs Vagrant Box password not working

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

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

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...

Saving docker container image

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)...

Why does `su` not work in Jenkins?

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. ...

Puppet inline template with puppet:// in URL

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...

Am I using puppet contain correctly?

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',...

Jenkins Console Output Error

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...

Is it possible to save an adobe pdf file using selenium web driver and one click build 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...

multiple similar files on one host from one template in 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....

Jenkins (cloudbees): remotely trigger build (e.g.via instant message) w/o creating user account in 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...

Jenkins continuous deployment error

I am learning Jenkins CI test & deploy as stated in the excellent tutorial 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...

Single Jenkins instance using multiple Sonar instances

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 do I print the current classpath for a Jenkins plugin?

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...

Build failure due to Sonar plugin

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( at org.sonar.runner.impl.BatchLauncher$ at Method) at org.sonar.runner.impl.BatchLauncher.doExecute( at org.sonar.runner.impl.BatchLauncher.execute( at...

Excluding jobs that haven't run recently from a view in 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...

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

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,...

using classes in 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...

how to add template file in 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...

determine if it is jenkins environment inside 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 } ...

How to dynamically create an environment variable?

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

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...

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

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...

Using external variable in rspec-puppet test

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...

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

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.

Install gradle on Centos

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, but when I unzipped I got gradle.bat file inside bin directory which tells me that this...

Display artifact in Jenkins Build description

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...

How to block a Jenkins job from running at certain times

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...

Vagrant + puppet + docker

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...

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

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...

Some of my tests show prepended with junit.framework

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 But I have 8 tests that have junit.framework prepended...

Jenkins Flexible Publish plugin if else condition

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...

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

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...

Retrieving command line -D options in Java

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....

How can I run the Jenkins jobs through terminal?

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

Triggering Jenkins to run application tests when GitHub PR is created

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...

Upgrade SonarQube issues

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...

Booting up Vagrant from Jenkins throws Permission Denied

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 [...