Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run via jenkins complains about autoload module layout #361

Closed
cdenneen opened this issue Nov 14, 2014 · 11 comments
Closed

Run via jenkins complains about autoload module layout #361

cdenneen opened this issue Nov 14, 2014 · 11 comments

Comments

@cdenneen
Copy link

I can't seem to reproduce this locally but it happens via Jenkins.

I've installed same rvm version locally but still no issues linting.

-bash-4.1$ bundle exec rake lint
manifests/exampleservice.pp - ERROR: exampleservice::exampleservice not in autoload module layout on line 19
manifests/init.pp - ERROR: exampleservice not in autoload module layout on line 19
rake aborted!

/var/lib/jenkins/.rvm/gems/ruby-2.0.0-p481/gems/puppet-lint-0.3.2/lib/puppet-lint/tasks/puppet-lint.rb:25:in block (2 levels) in initialize' /var/lib/jenkins/.rvm/gems/ruby-2.0.0-p481/gems/puppet-lint-0.3.2/lib/puppet-lint/tasks/puppet-lint.rb:13:inblock in initialize'
/var/lib/jenkins/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in eval' /var/lib/jenkins/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in

'
Tasks: TOP => lint
(See full trace by running task with --trace)

Using this repo to test:
https://github.com/myoung34/puppet-exampleservice

I end up having to add the following to Rakefile in order to get Jenkins to successfully build:

PuppetLint.configuration.send('disable_autoloader_layout')

@mark0n
Copy link

mark0n commented Dec 16, 2014

Please double check that the name of the directory to which Jenkins checks your code out matches the name of the Puppet module.

@mgagne
Copy link

mgagne commented Dec 16, 2014

This is what we did at StackForge for our puppet modules for OpenStack:
https://github.com/openstack-infra/project-config/blob/master/jenkins/jobs/macros.yaml#L104-L129

We parse Modulefile or metadata.json, create a folder with the module name, rsync files in it and run puppet-lint from that new folder.

@rnelson0
Copy link
Collaborator

@cdenneen Is this still an issue for you? If so, can you update to 2.0.0 and see if that resolves it? Thank you.

@drewhemm
Copy link

drewhemm commented Aug 1, 2016

I'm getting this issue with Atlassian Bamboo, when performing the following steps:

  1. Bamboo checks out a repo containing an R10K Puppetfile
  2. R10K is run to checkout the modules in the Puppetfile (into a 'modules' directory)
    3 I then run puppet-lint from the modules/MODULENAME directory. This is the code I have in my Rakefile:

sh "puppet-lint manifests --error-level error --no-2sp_soft_tabs-check"

When I SSH into the Bamboo box and cd into the set working directory and run puppet-lint, it completes without errors. Looks like something strange is going on with the path recognition...

@rnelson0
Copy link
Collaborator

rnelson0 commented Aug 1, 2016

@drewhemm When you run the test interactively, are you just running puppet-lint manifests --error-level error --no-2sp_soft_tabs-check as your user, or are you using sudo/su to run sh "puppet-lint manifests --error-level error --no-2sp_soft_tabs-check" as the bamboo service account?

I don't have a working Jenkins or Bamboo installation to test with myself.

@drewhemm
Copy link

drewhemm commented Aug 2, 2016

Seems I needed to add the --relative flag for it to work.

@rnelson0
Copy link
Collaborator

rnelson0 commented Aug 2, 2016

@drewhemm your Jenkins test step is now:

sh "puppet-lint manifests --relative --error-level error --no-2sp_soft_tabs-check"

And it works properly? Can we close this now?

@drewhemm
Copy link

drewhemm commented Aug 2, 2016

Confirmed. I've attached my Rakefile which is now working from Bamboo after adding --relative.

Rakefile.txt

I imagine the same solution applies to Jenkins

@rnelson0
Copy link
Collaborator

rnelson0 commented Aug 2, 2016

Awesome, thanks so much for the update Andrew!

@cdenneen I'm closing this out but if you can confirm at your leisure that you were able to resolve your issue with Jenkins that would be great. Thanks!

@rnelson0 rnelson0 closed this as completed Aug 2, 2016
@cdenneen
Copy link
Author

cdenneen commented Aug 9, 2016

@rnelson0 puppet-lint 0.3.2 this works fine without any special change.
puppet-lint 2.0.0 still has this error by default.

Creating a custom Rake task (most modules will use rspec helpers to have default rake tasks), probably isn't really a "fix" (Does work in a custom scenario):

  modules.each do |m|
    Dir.chdir("modules/" + m) do
      output = `puppet-lint manifests --error-level error --no-2sp_soft_tabs-check --relative`
      if !$?.success?
        puts output
        exit 1
      end

However the relative fix is configurable and does make v2.0.0 work so just want to explain here how that works if someone else stumbles upon this post:

  PuppetLint.configuration.relative = true

or something like

PuppetLint::RakeTask.new :lint do |config|
...
  # Compare module layout relative to the module root
  config.relative = true
...
end

Thanks @drewhemm for discovering this and @rnelson0 for the follow-ups.

@ghoneycutt
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants