diff --git a/.fixtures.yml b/.fixtures.yml index 087ac25d1..31b4009e1 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,3 +1,4 @@ +--- fixtures: repositories: apt: "https://github.com/puppetlabs/puppetlabs-apt" @@ -6,9 +7,5 @@ fixtures: zypprepo: "https://github.com/voxpupuli/puppet-zypprepo.git" archive: "https://github.com/voxpupuli/puppet-archive.git" systemd: "https://github.com/voxpupuli/puppet-systemd" - yumrepo_core: - repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git - puppet_version: ">= 6.0.0" - augeas_core: - repo: https://github.com/puppetlabs/puppetlabs-augeas_core.git - puppet_version: ">= 6.0.0" + yumrepo_core: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git + augeas_core: https://github.com/puppetlabs/puppetlabs-augeas_core.git diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6aaa603ff..daceb642f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -131,19 +131,29 @@ You can install all needed gems for spec tests into the modules directory by running: ```sh -bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" +bundle config set --local path '.vendor/' +bundle config set --local without 'development system_tests release' +bundle install --jobs "$(nproc)" ``` If you also want to run acceptance tests: ```sh -bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" ``` Our all in one solution if you don't know if you need to install or update gems: ```sh -bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" +bundle update +bundle clean ``` As an alternative to the `--jobs "$(nproc)` parameter, you can set an @@ -235,15 +245,23 @@ with: BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` +or + +```sh +BEAKER_PUPPET_COLLECTION=none BEAKER_setfile=archlinux-64 bundle exec rake beaker +``` + +This latter example will use the distribution's own version of Puppet. + You can replace the string `debian11` with any common operating system. The following strings are known to work: * ubuntu2004 * ubuntu2204 * debian11 -* centos7 -* centos8 +* debian12 * centos9 +* archlinux * almalinux8 * almalinux9 * fedora36 diff --git a/.rspec b/.github/labeler.yml similarity index 63% rename from .rspec rename to .github/labeler.yml index f634583de..f2d08d6b4 100644 --- a/.rspec +++ b/.github/labeler.yml @@ -1,5 +1,6 @@ +--- # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ ---format documentation ---color +skip-changelog: + - head-branch: ['^release-*', 'release'] diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..f5b5d7a99 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,42 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes + +changelog: + exclude: + labels: + - duplicate + - invalid + - modulesync + - question + - skip-changelog + - wont-fix + - wontfix + + categories: + - title: Breaking Changes 🛠 + labels: + - backwards-incompatible + + - title: New Features 🎉 + labels: + - enhancement + + - title: Bug Fixes 🐛 + labels: + - bug + + - title: Documentation Updates 📚 + labels: + - documentation + - docs + + - title: Dependency Updates ⬆️ + labels: + - dependencies + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a0779116..1f82c4c93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,12 @@ name: CI -on: pull_request +on: + pull_request: {} + push: + branches: + - main + - master concurrency: group: ${{ github.ref_name }} @@ -13,6 +18,4 @@ concurrency: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 - with: - pidfile_workaround: 'false' + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 000000000..66127cd0b --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,17 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: "Pull Request Labeler" + +on: + pull_request_target: {} + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15f172134..93b33c2bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ on: jobs: release: name: Release - uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1 + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2 with: allowed_owner: 'voxpupuli' secrets: @@ -20,3 +20,10 @@ jobs: # https://docs.github.com/en/actions/security-guides/encrypted-secrets username: ${{ secrets.PUPPET_FORGE_USERNAME }} api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} + + create-github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + steps: + - name: Create GitHub release + uses: voxpupuli/gha-create-a-github-release@v1 diff --git a/.gitignore b/.gitignore index 84fd904ca..adea1b017 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ .*.sw? /.yardoc/ /Guardfile +bolt-debug.log +.rerun.json diff --git a/.msync.yml b/.msync.yml index dd3e95722..95e8c977c 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '7.0.0' +modulesync_config_version: '9.1.0' diff --git a/.overcommit.yml b/.overcommit.yml index d367adaea..4ed994cc5 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -43,10 +43,12 @@ PreCommit: enabled: true description: 'Runs rubocop on modified files only' command: ['bundle', 'exec', 'rubocop'] - PuppetLint: + RakeTarget: enabled: true - description: 'Runs puppet-lint on modified files only' - command: ['bundle', 'exec', 'puppet-lint'] + description: 'Runs lint on modified files only' + targets: + - 'lint' + command: ['bundle', 'exec', 'rake'] YamlSyntax: enabled: true JsonSyntax: diff --git a/.pmtignore b/.pmtignore index 58a040887..10b983069 100644 --- a/.pmtignore +++ b/.pmtignore @@ -35,3 +35,4 @@ /.yardoc/ /.yardopts /Dockerfile +/HISTORY.md diff --git a/.puppet-lint.rc b/.puppet-lint.rc index dd8272c7b..05d28a260 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,3 +1,6 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + --fail-on-warnings --no-parameter_documentation-check --no-parameter_types-check diff --git a/.rspec_parallel b/.rspec_parallel deleted file mode 100644 index a9a84f852..000000000 --- a/.rspec_parallel +++ /dev/null @@ -1,4 +0,0 @@ -# Managed by modulesync - DO NOT EDIT -# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ - ---format progress diff --git a/.sync.yml b/.sync.yml index c645ca804..35775e974 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,7 +1,3 @@ --- -Gemfile: - optional: - ':test': - - gem: 'retries' .rubocop.yml: unmanaged: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ed0a4b8c..4dba11a9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v5.0.0](https://github.com/voxpupuli/puppet-jenkins/tree/v5.0.0) (2024-05-07) + +[Full Changelog](https://github.com/voxpupuli/puppet-jenkins/compare/v4.0.0...v5.0.0) + +**Breaking changes:** + +- CentOS: Drop EoL 7/8 support [\#1106](https://github.com/voxpupuli/puppet-jenkins/pull/1106) ([bastelfreak](https://github.com/bastelfreak)) +- Use native Puppet instead of the retries Gem in the CLI provider, replacing try\_sleep parameter by exponential backoff [\#904](https://github.com/voxpupuli/puppet-jenkins/pull/904) ([ekohl](https://github.com/ekohl)) + +**Implemented enhancements:** + +- update puppet-systemd upper bound to 8.0.0 [\#1102](https://github.com/voxpupuli/puppet-jenkins/pull/1102) ([TheMeier](https://github.com/TheMeier)) +- Add support for Puppet 8 [\#1095](https://github.com/voxpupuli/puppet-jenkins/pull/1095) ([evgeni](https://github.com/evgeni)) +- Add support for puppetlabs/java 11.x [\#1094](https://github.com/voxpupuli/puppet-jenkins/pull/1094) ([evgeni](https://github.com/evgeni)) +- replace deprecated `merge` function with native puppet [\#1092](https://github.com/voxpupuli/puppet-jenkins/pull/1092) ([zilchms](https://github.com/zilchms)) +- Remove legacy top-scope syntax [\#1084](https://github.com/voxpupuli/puppet-jenkins/pull/1084) ([smortex](https://github.com/smortex)) +- Add download option to jenkins module [\#1073](https://github.com/voxpupuli/puppet-jenkins/pull/1073) ([ekohl](https://github.com/ekohl)) + ## [v4.0.0](https://github.com/voxpupuli/puppet-jenkins/tree/v4.0.0) (2023-09-29) [Full Changelog](https://github.com/voxpupuli/puppet-jenkins/compare/v3.3.0...v4.0.0) @@ -224,7 +242,7 @@ These should not affect the functionality of the module. - systemd jenkins master support on RedHat [\#694](https://github.com/voxpupuli/puppet-jenkins/pull/694) ([jhoblitt](https://github.com/jhoblitt)) - fix slave systemd support [\#692](https://github.com/voxpupuli/puppet-jenkins/pull/692) ([jhoblitt](https://github.com/jhoblitt)) - add swarm client systemd support [\#691](https://github.com/voxpupuli/puppet-jenkins/pull/691) ([jhoblitt](https://github.com/jhoblitt)) -- add ::jenkins::sysconfdir parameter [\#689](https://github.com/voxpupuli/puppet-jenkins/pull/689) ([jhoblitt](https://github.com/jhoblitt)) +- add jenkins::sysconfdir parameter [\#689](https://github.com/voxpupuli/puppet-jenkins/pull/689) ([jhoblitt](https://github.com/jhoblitt)) - disable plugin pinning by default [\#688](https://github.com/voxpupuli/puppet-jenkins/pull/688) ([jhoblitt](https://github.com/jhoblitt)) - add firewall module dependency info [\#676](https://github.com/voxpupuli/puppet-jenkins/pull/676) ([vinhut](https://github.com/vinhut)) - Add support for gitlab api token credential - \#664 [\#667](https://github.com/voxpupuli/puppet-jenkins/pull/667) ([ripclawffb](https://github.com/ripclawffb)) @@ -245,7 +263,7 @@ These should not affect the functionality of the module. - Won't install alongside puppetlabs-mysql [\#623](https://github.com/voxpupuli/puppet-jenkins/issues/623) - uninitialized constant json when using Jenkins\_credentials provider [\#617](https://github.com/voxpupuli/puppet-jenkins/issues/617) - `jenkins_user` experimental password setting is broken [\#499](https://github.com/voxpupuli/puppet-jenkins/issues/499) -- Ensure $::jenkins::localstatedir to Directory Breaks Filesystem's With Symlinked Mounts [\#403](https://github.com/voxpupuli/puppet-jenkins/issues/403) +- Ensure $jenkins::localstatedir to Directory Breaks Filesystem's With Symlinked Mounts [\#403](https://github.com/voxpupuli/puppet-jenkins/issues/403) - repo::debian.pp does not work with apt module \>= 2.0.0 [\#402](https://github.com/voxpupuli/puppet-jenkins/issues/402) - Jenkins Plugin manifest are now readable since it has got some invalid byte sequence in US-ASCII [\#265](https://github.com/voxpupuli/puppet-jenkins/issues/265) - Default INFO logging makes jenkins cli output messages that are then … [\#907](https://github.com/voxpupuli/puppet-jenkins/pull/907) ([jhooyberghs](https://github.com/jhooyberghs)) @@ -302,7 +320,7 @@ These should not affect the functionality of the module. - setting security is not idempotent [\#673](https://github.com/voxpupuli/puppet-jenkins/issues/673) - 'digest\_type' default of 'sha1' is causing all plugins to install repeatedly [\#668](https://github.com/voxpupuli/puppet-jenkins/issues/668) - puppet\_helper.groovy throws an error with unsupported credentials [\#664](https://github.com/voxpupuli/puppet-jenkins/issues/664) -- $::jenkins::libdir is undef in jenkins::cli class [\#654](https://github.com/voxpupuli/puppet-jenkins/issues/654) +- $jenkins::libdir is undef in jenkins::cli class [\#654](https://github.com/voxpupuli/puppet-jenkins/issues/654) - Unsuccessful Installation [\#647](https://github.com/voxpupuli/puppet-jenkins/issues/647) - jenkins::plugins doesn't work properly with puppet 4.6.2 [\#637](https://github.com/voxpupuli/puppet-jenkins/issues/637) - Allow virtual jenkins host [\#630](https://github.com/voxpupuli/puppet-jenkins/issues/630) @@ -440,7 +458,7 @@ These should not affect the functionality of the module. - jenkins-slave don't stop correctly [\#557](https://github.com/voxpupuli/puppet-jenkins/issues/557) - jenkins\_job broken by org.jenkinsci.plugins.workflow.job.WorkflowJob jobs [\#551](https://github.com/voxpupuli/puppet-jenkins/issues/551) - Parameter jenkins::slave::ui\_pass not enclosed in quotes. [\#542](https://github.com/voxpupuli/puppet-jenkins/issues/542) -- ::jenkins::slave should not depend on ::jenkins [\#533](https://github.com/voxpupuli/puppet-jenkins/issues/533) +- jenkins::slave should not depend on jenkins [\#533](https://github.com/voxpupuli/puppet-jenkins/issues/533) - slow unit test causing travis failures [\#517](https://github.com/voxpupuli/puppet-jenkins/issues/517) - jenkins:plugin can incorrectly believe a plugin is installed \(when it isn't\) [\#513](https://github.com/voxpupuli/puppet-jenkins/issues/513) - jenkins::plugin ignores version changes [\#512](https://github.com/voxpupuli/puppet-jenkins/issues/512) @@ -497,7 +515,7 @@ These should not affect the functionality of the module. - Plugins specified by version number are not updated [\#445](https://github.com/voxpupuli/puppet-jenkins/issues/445) - Passing an array to jenkins::plugin [\#429](https://github.com/voxpupuli/puppet-jenkins/issues/429) - Unable to persist firewall rules: Execution of '/usr/libexec/iptables/iptables.init save' returned 1: [\#424](https://github.com/voxpupuli/puppet-jenkins/issues/424) -- $::jenkins::port does not properly manage listening port [\#416](https://github.com/voxpupuli/puppet-jenkins/issues/416) +- $jenkins::port does not properly manage listening port [\#416](https://github.com/voxpupuli/puppet-jenkins/issues/416) - Using Plugin Hash Exec Test for plugin Fails [\#410](https://github.com/voxpupuli/puppet-jenkins/issues/410) - jenkins::job::present issue [\#409](https://github.com/voxpupuli/puppet-jenkins/issues/409) - Using Direct URL for plug-ins restarts jenkins with every puppet run [\#408](https://github.com/voxpupuli/puppet-jenkins/issues/408) @@ -518,7 +536,7 @@ These should not affect the functionality of the module. - replace centos-7-docker fakesystemd with classic flavor [\#550](https://github.com/voxpupuli/puppet-jenkins/pull/550) ([jhoblitt](https://github.com/jhoblitt)) - travis puppet versions [\#549](https://github.com/voxpupuli/puppet-jenkins/pull/549) ([jhoblitt](https://github.com/jhoblitt)) - fix beaker acceptance tests on Ubuntu [\#548](https://github.com/voxpupuli/puppet-jenkins/pull/548) ([jhoblitt](https://github.com/jhoblitt)) -- simplify ::jenkins::slave ordering logic [\#547](https://github.com/voxpupuli/puppet-jenkins/pull/547) ([jhoblitt](https://github.com/jhoblitt)) +- simplify jenkins::slave ordering logic [\#547](https://github.com/voxpupuli/puppet-jenkins/pull/547) ([jhoblitt](https://github.com/jhoblitt)) - skip pending beaker tests [\#546](https://github.com/voxpupuli/puppet-jenkins/pull/546) ([jhoblitt](https://github.com/jhoblitt)) - minor puppet\_helper.groovy cleanup [\#543](https://github.com/voxpupuli/puppet-jenkins/pull/543) ([jhoblitt](https://github.com/jhoblitt)) - Improve spec speed [\#537](https://github.com/voxpupuli/puppet-jenkins/pull/537) ([petems](https://github.com/petems)) @@ -638,7 +656,7 @@ These should not affect the functionality of the module. * [#275](https://github.com/jenkinsci/puppet-jenkins/pull/275) - add .bundle to .gitignore * [#276](https://github.com/jenkinsci/puppet-jenkins/pull/276) - add log/ to .gitignore * [#277](https://github.com/jenkinsci/puppet-jenkins/pull/277) - add puppet 3.7.0 to travis matrix -* [#278](https://github.com/jenkinsci/puppet-jenkins/pull/278) - remove unnecessary whitespace from $::jenkins::cli_helper::helper_cmd +* [#278](https://github.com/jenkinsci/puppet-jenkins/pull/278) - remove unnecessary whitespace from $jenkins::cli_helper::helper_cmd * [#279](https://github.com/jenkinsci/puppet-jenkins/pull/279) - add metadata-json-lint to Gemfile & enable rake validate target * [#280](https://github.com/jenkinsci/puppet-jenkins/pull/280) - change puppetlabs/stdlib version dep to >= 4.6.0 * [#282](https://github.com/jenkinsci/puppet-jenkins/pull/282) - Feature/puppet 4 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 8dd82d636..000000000 --- a/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# MANAGED BY MODULESYNC -# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ - -FROM ruby:2.7 - -WORKDIR /opt/puppet - -# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 -RUN mkdir -p /etc/sv - -ARG PUPPET_GEM_VERSION="~> 6.0" -ARG PARALLEL_TEST_PROCESSORS=4 - -# Cache gems -COPY Gemfile . -RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle} - -COPY . . - -RUN bundle install -RUN bundle exec rake release_checks - -# Container should not saved -RUN exit 1 diff --git a/Gemfile b/Gemfile index 7e02fe691..7123c6636 100644 --- a/Gemfile +++ b/Gemfile @@ -4,11 +4,10 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 7.0', :require => false + gem 'voxpupuli-test', '~> 9.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'puppet_metadata', '~> 3.0', :require => false - gem 'retries', :require => false + gem 'puppet_metadata', '~> 4.0', :require => false end group :development do @@ -17,13 +16,11 @@ group :development do end group :system_tests do - gem 'voxpupuli-acceptance', '~> 2.0', :require => false + gem 'voxpupuli-acceptance', '~> 3.0', :require => false end group :release do - gem 'github_changelog_generator', '>= 1.16.1', :require => false - gem 'voxpupuli-release', '~> 3.0', :require => false - gem 'faraday-retry', '~> 2.1', :require => false + gem 'voxpupuli-release', '~> 3.0', :require => false end gem 'rake', :require => false diff --git a/HISTORY.md b/HISTORY.md index b58e28133..4c2d21a49 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -89,7 +89,7 @@ * [#275](https://github.com/jenkinsci/puppet-jenkins/pull/275) - add .bundle to .gitignore * [#276](https://github.com/jenkinsci/puppet-jenkins/pull/276) - add log/ to .gitignore * [#277](https://github.com/jenkinsci/puppet-jenkins/pull/277) - add puppet 3.7.0 to travis matrix -* [#278](https://github.com/jenkinsci/puppet-jenkins/pull/278) - remove unnecessary whitespace from $::jenkins::cli_helper::helper_cmd +* [#278](https://github.com/jenkinsci/puppet-jenkins/pull/278) - remove unnecessary whitespace from $jenkins::cli_helper::helper_cmd * [#279](https://github.com/jenkinsci/puppet-jenkins/pull/279) - add metadata-json-lint to Gemfile & enable rake validate target * [#280](https://github.com/jenkinsci/puppet-jenkins/pull/280) - change puppetlabs/stdlib version dep to >= 4.6.0 * [#282](https://github.com/jenkinsci/puppet-jenkins/pull/282) - Feature/puppet 4 diff --git a/NATIVE_TYPES_AND_PROVIDERS.md b/NATIVE_TYPES_AND_PROVIDERS.md index d9dd05deb..018ada7d1 100644 --- a/NATIVE_TYPES_AND_PROVIDERS.md +++ b/NATIVE_TYPES_AND_PROVIDERS.md @@ -114,15 +114,13 @@ master service to be running. Most require the presence of sufficiently for all providers to function. ``` -class { '::jenkins': +class { 'jenkins': install_java => true, cli => true, } -include ::jenkins::cli_helper +include jenkins::cli_helper ``` -The ruby gem `retries` is presently required by all providers. - ### `puppetserver` There is a known issue with `puppetserver` being unable to load code from @@ -141,13 +139,6 @@ jruby-puppet: { See [SERVER-973](https://tickets.puppetlabs.com/browse/SERVER-973) -Additionally, the `retries` gem is required. This may be installed on the master by running: - -``` -/opt/puppetlabs/bin/puppetserver gem install retries -``` - - Types -- diff --git a/README.md b/README.md index a3e98cb80..47f3801a7 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,12 @@ This module has been adjusted to support the new CLI. The CLI supports proper authentication with username and password. It's a requirement for supporting AD and OpenID authentications (there is no ssh key -there). You can supply ```$::jenkins::cli_username``` and -```$::jenkins::cli_password``` to use username / password based authentication. +there). You can supply ```$jenkins::cli_username``` and +```$jenkins::cli_password``` to use username / password based authentication. Then the puppet automation user can also reside in A.D Note: Jenkins requires a ssh username, so you must also provide -```$::jenkins::cli_username``` for ssh. If you specify both username/password +```$jenkins::cli_username``` for ssh. If you specify both username/password and ssh key file, SSH authentication is preferred. # Using puppet-jenkins diff --git a/lib/puppet/feature/retries.rb b/lib/puppet/feature/retries.rb deleted file mode 100644 index 426565f6a..000000000 --- a/lib/puppet/feature/retries.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -require 'puppet/util/feature' - -Puppet.features.add(:retries, libs: 'retries') diff --git a/lib/puppet/parser/functions/jenkins_port.rb b/lib/puppet/parser/functions/jenkins_port.rb index 3461b050b..023eb8e0b 100644 --- a/lib/puppet/parser/functions/jenkins_port.rb +++ b/lib/puppet/parser/functions/jenkins_port.rb @@ -10,7 +10,7 @@ module Puppet::Parser::Functions $port = jenkins_port() ENDHEREDOC - config_hash = lookupvar('::jenkins::config_hash') + config_hash = lookupvar('jenkins::config_hash') config_hash&.dig('JENKINS_PORT', 'value') || 8080 end end diff --git a/lib/puppet/parser/functions/jenkins_prefix.rb b/lib/puppet/parser/functions/jenkins_prefix.rb index 80a6a55bd..444c5bcbf 100644 --- a/lib/puppet/parser/functions/jenkins_prefix.rb +++ b/lib/puppet/parser/functions/jenkins_prefix.rb @@ -10,7 +10,7 @@ module Puppet::Parser::Functions $prefix = jenkins_prefix() ENDHEREDOC - config_hash = lookupvar('::jenkins::config_hash') + config_hash = lookupvar('jenkins::config_hash') config_hash&.dig('PREFIX', 'value') || '' end end diff --git a/lib/puppet/x/jenkins/config.rb b/lib/puppet/x/jenkins/config.rb index 1a0556d89..e32c8092a 100644 --- a/lib/puppet/x/jenkins/config.rb +++ b/lib/puppet/x/jenkins/config.rb @@ -18,7 +18,6 @@ class UnknownConfig < ArgumentError; end ssh_private_key: nil, puppet_helper: '/usr/share/java/puppet_helper.groovy', cli_tries: 30, - cli_try_sleep: 2, cli_username: nil, cli_password: nil, cli_password_file: '/tmp/jenkins_credentials_for_puppet', diff --git a/lib/puppet/x/jenkins/provider/cli.rb b/lib/puppet/x/jenkins/provider/cli.rb index 6057cdc48..c979940ea 100644 --- a/lib/puppet/x/jenkins/provider/cli.rb +++ b/lib/puppet/x/jenkins/provider/cli.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'puppet/provider' +require 'puppet/util/retry_action' require 'facter' require 'json' @@ -31,7 +32,6 @@ def self.inherited(subclass) # rubocop:todo Lint/MissingSuper initvars commands java: 'java' - confine feature: :retries # subclasses should inherit this value once it has been determined that # jenkins requires authorization, it shortens the run time be elemating the @@ -170,7 +170,6 @@ def self.execute_with_retry(command, options = {}, cli_pre_cmd = []) url = config[:url] ssh_private_key = config[:ssh_private_key] cli_tries = config[:cli_tries] - cli_try_sleep = config[:cli_try_sleep] cli_username = config[:cli_username] cli_password = config[:cli_password] cli_password_file = config[:cli_password_file] @@ -202,16 +201,7 @@ def self.execute_with_retry(command, options = {}, cli_pre_cmd = []) # retry on "unknown" execution errors but don't catch AuthErrors. If an # AuthError has bubbled up to this level it means either an ssh_private_key # is required and we don't have one or that one we have was rejected. - handler = proc do |exception, attempt_number, total_delay| - Puppet.debug("#{sname} caught #{exception.class.to_s.match(%r{::([^:]+)$})[1]}; retry attempt #{attempt_number}; #{total_delay.round(3)} seconds have passed") - end - with_retries( - max_tries: cli_tries, - base_sleep_seconds: 1, - max_sleep_seconds: cli_try_sleep, - rescue: [UnknownError, NetError], - handler: handler - ) do + Puppet::Util::RetryAction.retry_action(retries: cli_tries, retry_exceptions: [UnknownError, NetError]) do result = execute_with_auth(cli_cmd, auth_cmd, options) Puppet.debug("#{sname} command stdout:\n#{result}") unless result == '' return result @@ -262,7 +252,8 @@ def self.execute_exceptionify(cmd, options) 'SEVERE: I/O error in channel CLI connection', 'java.net.SocketException: Connection reset', 'java.net.ConnectException: Connection refused', - 'java.io.IOException: Failed to connect' + 'java.io.IOException: Failed to connect', + 'java.io.IOException: Server returned HTTP response code: 503' ] if options.key?(:tmpfile_as_param) diff --git a/manifests/cli.pp b/manifests/cli.pp index abad8ebe6..29336b6ea 100644 --- a/manifests/cli.pp +++ b/manifests/cli.pp @@ -6,7 +6,7 @@ include jenkins # XXX Classes/defines which include the jenkins::cli class assume that they - # can use the cli even if $::jenkins::cli == false. This breaks the top + # can use the cli even if $jenkins::cli == false. This breaks the top # level anchor pattern. The cli param should either be deprecated and # essentially hardwired to true or attempting to use cli functionality # without this param set should fail; either option is a backwards @@ -72,7 +72,7 @@ require => File[$jar], } - # jenkins::cli::reload should be included only after $::jenkins::cli::cmd is + # jenkins::cli::reload should be included only after $jenkins::cli::cmd is # defined include jenkins::cli::reload } diff --git a/manifests/cli/config.pp b/manifests/cli/config.pp index 1c815ba67..0b1e71ec6 100644 --- a/manifests/cli/config.pp +++ b/manifests/cli/config.pp @@ -17,28 +17,10 @@ Boolean $cli_password_file_exists = false, Optional[String] $ssh_private_key_content = undef, ) { - if str2bool($facts['is_pe']) { - $gem_provider = 'pe_gem' - # lint:ignore:legacy_facts - } elsif $facts['rubysitedir'] and ('/opt/puppetlabs/puppet/lib/ruby' in $facts['rubysitedir']) { - # lint:endignore - # AIO puppet - $gem_provider = 'puppet_gem' - } else { - $gem_provider = 'gem' - } - # lint:ignore:legacy_facts $is_root = $facts['id'] == 'root' # lint:endignore - # required by PuppetX::Jenkins::Provider::Clihelper base - if ! defined(Package['retries']) { - package { 'retries': - provider => $gem_provider, - } - } - if $ssh_private_key and $ssh_private_key_content { file { $ssh_private_key: ensure => 'file', diff --git a/manifests/init.pp b/manifests/init.pp index 424b665ab..0f5e89761 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -325,7 +325,7 @@ if $cli_ssh_keyfile { # SSH key auth if empty($cli_username) { - fail('ERROR: Latest remoting free CLI (see https://issues.jenkins-ci.org/browse/JENKINS-41745) needs username for SSH Access (\$::jenkins::cli_username)') + fail('ERROR: Latest remoting free CLI (see https://issues.jenkins-ci.org/browse/JENKINS-41745) needs username for SSH Access (\$jenkins::cli_username)') } $_cli_auth_arg = "-i '${cli_ssh_keyfile}' -ssh -user '${cli_username}'" } elsif !empty($cli_username) { diff --git a/manifests/job/present.pp b/manifests/job/present.pp index 1a3a402cd..34dc2419f 100644 --- a/manifests/job/present.pp +++ b/manifests/job/present.pp @@ -66,7 +66,7 @@ $job_dir = "${jenkins::job_dir}/${job_subdir_name}" $config_path = "${job_dir}/config.xml" - # Bring variables from Class['::jenkins'] into local scope. + # Bring variables from Class['jenkins'] into local scope. $cli_tries = $jenkins::cli_tries $cli_try_sleep = $jenkins::cli_try_sleep diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 1fb6f7558..595c71393 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -45,17 +45,21 @@ # Pin the plugin to a specific version. This prevents the updater from # updating it. # +# @param download_options +# Add options to Archive's curl +# define jenkins::plugin ( - Optional[String] $version = undef, - Optional[String] $config_filename = undef, - Optional[String] $config_content = undef, - Optional[String] $update_url = undef, - Optional[String] $source = undef, - Enum['hpi', 'jpi'] $extension = 'hpi', - Optional[String] $digest_string = undef, - Boolean $enabled = true, - String $digest_type = 'sha1', - Boolean $pin = false, + Optional[String] $version = undef, + Optional[String] $config_filename = undef, + Optional[String] $config_content = undef, + Optional[String] $update_url = undef, + Optional[String] $source = undef, + Enum['hpi', 'jpi'] $extension = 'hpi', + Optional[String] $digest_string = undef, + Boolean $enabled = true, + String $digest_type = 'sha1', + Boolean $pin = false, + Array[String[1]] $download_options = ($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '7') ? { true => [], default => ['--http1.1'] }, ) { include jenkins @@ -186,16 +190,17 @@ command => "/bin/rm -rf ${jenkins::plugin_dir}/${plugin}", } -> archive { $plugin: - source => $download_url, - path => "${jenkins::plugin_dir}/${plugin}", - checksum_verify => $checksum_verify, - checksum => $checksum, - checksum_type => $checksum_type, - proxy_server => $jenkins::proxy::url, - cleanup => false, - extract => false, - require => $plugindir, - notify => $notify, + source => $download_url, + path => "${jenkins::plugin_dir}/${plugin}", + checksum_verify => $checksum_verify, + checksum => $checksum, + checksum_type => $checksum_type, + proxy_server => $jenkins::proxy::url, + cleanup => false, + extract => false, + require => $plugindir, + notify => $notify, + download_options => $download_options, } $archive_require = Archive[$plugin] } else { diff --git a/manifests/user_setup.pp b/manifests/user_setup.pp index 886ac3e4d..63fab79d1 100644 --- a/manifests/user_setup.pp +++ b/manifests/user_setup.pp @@ -55,10 +55,7 @@ # On Debian the service is started by default so it must be configured prior # to installation which is why it's configured in this file rather than config.pp - $config_hash = merge( - $jenkins::params::config_hash_defaults, - $jenkins::config_hash - ) + $config_hash = $jenkins::params::config_hash_defaults + $jenkins::config_hash systemd::dropin_file { 'puppet-overrides.conf': unit => 'jenkins.service', diff --git a/metadata.json b/metadata.json index f27c75554..6d81305eb 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-jenkins", - "version": "4.0.0", + "version": "5.0.1-rc0", "author": "Vox Pupuli", "license": "Apache-2.0", "summary": "Manage the Jenkins continuous integration service with Puppet", @@ -24,8 +24,6 @@ { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "7", - "8", "9" ] }, @@ -85,7 +83,7 @@ }, { "name": "puppetlabs/java", - "version_requirement": ">= 1.0.1 < 11.0.0" + "version_requirement": ">= 1.0.1 < 12.0.0" }, { "name": "puppet/zypprepo", @@ -97,13 +95,13 @@ }, { "name": "puppet/systemd", - "version_requirement": ">= 3.1.0 < 7.0.0" + "version_requirement": ">= 3.1.0 < 8.0.0" } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ] } diff --git a/spec/acceptance/hieradata/os/RedHat.yaml b/spec/acceptance/hieradata/family/RedHat.yaml similarity index 100% rename from spec/acceptance/hieradata/os/RedHat.yaml rename to spec/acceptance/hieradata/family/RedHat.yaml diff --git a/spec/acceptance/xtypes/jenkins_credentials_spec.rb b/spec/acceptance/xtypes/jenkins_credentials_spec.rb index 265307afb..d778aa3a8 100644 --- a/spec/acceptance/xtypes/jenkins_credentials_spec.rb +++ b/spec/acceptance/xtypes/jenkins_credentials_spec.rb @@ -8,7 +8,9 @@ context 'UsernamePasswordCredentialsImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins_credentials { '9b07d668-a87e-4877-9407-ae05056e32ac': ensure => 'present', @@ -36,15 +38,22 @@ context 'ConduitCredentialsImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { [ + 'apache-httpcomponents-client-4-api', + 'caffeine-api', 'command-launcher', + 'gson-api', 'jaxb', 'jdk-tool', + 'mina-sshd-api-common', 'mina-sshd-api-core', 'phabricator-plugin', + 'script-security', 'sshd', 'trilead-api', ]: } @@ -74,11 +83,15 @@ context 'BasicSSHUserPrivateKey' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { [ + 'gson-api', 'ssh-credentials', + 'variant', 'trilead-api', ]: } @@ -109,10 +122,11 @@ context 'StringCredentialsImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { 'plain-credentials': - pin => true, } jenkins_credentials { '150b2895-b0eb-4813-b8a5-3779690c063c': @@ -140,10 +154,11 @@ context 'FileCredentialsImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { 'plain-credentials': - pin => true, } jenkins_credentials { '95bfe159-8bf0-4605-be20-47e201220e7c': @@ -172,7 +187,9 @@ context 'AWSCredentialsImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { [ 'apache-httpcomponents-client-4-api', @@ -193,8 +210,11 @@ 'aws-java-sdk-ssm', 'caffeine-api', 'credentials-binding', + 'gson-api', 'jackson2-api', 'jaxb', + 'joda-time-api', + 'json-api', 'plain-credentials', 'script-security', 'snakeyaml-api', @@ -228,10 +248,13 @@ context 'GitLabApiTokenImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config package { 'git': } jenkins::plugin { [ + 'asm-api', 'apache-httpcomponents-client-4-api', 'bootstrap5-api', 'caffeine-api', @@ -245,14 +268,17 @@ 'git', 'git-client', 'gitlab-plugin', + 'gson-api', 'ionicons-api', 'jackson2-api', 'jakarta-activation-api', 'jakarta-mail-api', 'jaxb', 'jersey2-api', + 'joda-time-api', 'jquery3-api', 'jsch', + 'json-api', 'junit', 'mailer', 'matrix-project', @@ -267,12 +293,15 @@ 'ssh-credentials', 'sshd', 'trilead-api', + 'variant', 'workflow-api', - 'workflow-job', 'workflow-scm-step', 'workflow-step-api', 'workflow-support', ]: } + jenkins::plugin { 'workflow-job': + version => '1400.v7fd111b_ec82f' + } jenkins_credentials { '7e86e9fb-a8af-480f-b596-7191dc02bf38': ensure => 'present', @@ -296,10 +325,13 @@ context 'BrowserStackCredentials' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { [ 'ace-editor', + 'asm-api', 'apache-httpcomponents-client-4-api', 'bootstrap5-api', 'browserstack-integration', @@ -312,10 +344,15 @@ 'durable-task', 'echarts-api', 'font-awesome-api', + 'gson-api', 'ionicons-api', 'jackson2-api', + 'jakarta-activation-api', + 'jakarta-mail-api', 'jaxb', + 'joda-time-api', 'jquery3-api', + 'json-api', 'junit', 'mailer', 'plain-credentials', @@ -326,15 +363,18 @@ 'snakeyaml-api', 'ssh-credentials', 'trilead-api', + 'variant', 'workflow-api', 'workflow-basic-steps', 'workflow-cps', 'workflow-durable-task-step', - 'workflow-job', 'workflow-scm-step', 'workflow-step-api', 'workflow-support', ]: } + jenkins::plugin { 'workflow-job': + version => '1400.v7fd111b_ec82f' + } jenkins_credentials { '562fa23d-a441-4cab-997f-58df6e245813': ensure => 'present', @@ -367,7 +407,9 @@ context 'StringCredentialsImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { 'plain-credentials': } @@ -396,10 +438,11 @@ context 'FileCredentialsImpl' do it 'works with no errors and idempotently' do pp = <<-EOS - include jenkins + class {'jenkins': + purge_plugins => true, + } include jenkins::cli::config jenkins::plugin { 'plain-credentials': - pin => true, } jenkins_credentials { '95bfe159-8bf0-4605-be20-47e201220e7c': diff --git a/spec/acceptance/xtypes/jenkins_job_spec.rb b/spec/acceptance/xtypes/jenkins_job_spec.rb index 21e9d8c99..1c14bba2c 100644 --- a/spec/acceptance/xtypes/jenkins_job_spec.rb +++ b/spec/acceptance/xtypes/jenkins_job_spec.rb @@ -107,7 +107,10 @@ <<-EOS include jenkins include jenkins::cli::config - jenkins::plugin { 'cloudbees-folder': } + jenkins::plugin { 'ionicons-api': } + jenkins::plugin { 'cloudbees-folder': + version => '6.897.vb_943ea_6b_a_08b_' + } EOS end diff --git a/spec/classes/cli/config_spec.rb b/spec/classes/cli/config_spec.rb index 9069004ba..4b998bf2a 100644 --- a/spec/classes/cli/config_spec.rb +++ b/spec/classes/cli/config_spec.rb @@ -126,26 +126,6 @@ end end end - - describe 'package gem provider' do - context 'is_pe fact' do - context 'true' do - let :facts do - super().merge(is_pe: true) - end - - it { is_expected.to contain_package('retries').with(provider: 'pe_gem') } - end - - context 'false' do - let :facts do - super().merge(is_pe: false) - end - - it { is_expected.to contain_package('retries').with(provider: 'gem') } - end - end - end end end end diff --git a/spec/functions/jenkins_prefix_spec.rb b/spec/functions/jenkins_prefix_spec.rb index 7669011c2..4cd829c0d 100644 --- a/spec/functions/jenkins_prefix_spec.rb +++ b/spec/functions/jenkins_prefix_spec.rb @@ -9,7 +9,7 @@ context 'with default parameters' do let(:pre_condition) do - 'include ::jenkins' + 'include jenkins' end it { is_expected.to run.with_params.and_return('') } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9efb4ae62..58c9b66ab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,6 +9,10 @@ require 'voxpupuli/test/spec_helper' +RSpec.configure do |c| + c.facterdb_string_keys = false +end + add_mocked_facts! if File.exist?(File.join(__dir__, 'default_module_facts.yml')) diff --git a/spec/unit/puppet/x/jenkins/config_spec.rb b/spec/unit/puppet/x/jenkins/config_spec.rb index 02221d7d1..583c47bb0 100644 --- a/spec/unit/puppet/x/jenkins/config_spec.rb +++ b/spec/unit/puppet/x/jenkins/config_spec.rb @@ -10,8 +10,7 @@ url: 'http://localhost:8080', ssh_private_key: nil, puppet_helper: '/usr/share/java/puppet_helper.groovy', - cli_tries: 30, - cli_try_sleep: 2 + cli_tries: 30 }.freeze shared_context 'facts' do @@ -21,7 +20,6 @@ Facter.add(:jenkins_ssh_private_key) { setcode { 'fact.id_rsa' } } Facter.add(:jenkins_puppet_helper) { setcode { 'fact.groovy' } } Facter.add(:jenkins_cli_tries) { setcode { 22 } } - Facter.add(:jenkins_cli_try_sleep) { setcode { 33 } } end end @@ -126,8 +124,7 @@ url: 'http://localhost:111', ssh_private_key: 'cat.id_rsa', puppet_helper: 'cat.groovy', - cli_tries: 222, - cli_try_sleep: 333 + cli_tries: 222 ) catalog.add_resource jenkins diff --git a/spec/unit/puppet/x/jenkins/provider/cli_spec.rb b/spec/unit/puppet/x/jenkins/provider/cli_spec.rb index b74e067ec..744c6f103 100644 --- a/spec/unit/puppet/x/jenkins/provider/cli_spec.rb +++ b/spec/unit/puppet/x/jenkins/provider/cli_spec.rb @@ -3,9 +3,6 @@ require 'spec_helper' require 'unit/puppet/x/spec_jenkins_providers' -# we need to make sure retries is always loaded or random test ordering can -# cause failures when a side effect hasn't yet caused the lib to be loaded -require 'retries' require 'puppet/x/jenkins/provider/cli' describe Puppet::X::Jenkins::Provider::Cli do @@ -38,7 +35,6 @@ Facter.add(:jenkins_puppet_helper) { setcode { 'fact.groovy' } } Facter.add(:jenkins_cli_username) { setcode { 'myuser' } } Facter.add(:jenkins_cli_tries) { setcode { 22 } } - Facter.add(:jenkins_cli_try_sleep) { setcode { 33 } } end end @@ -316,13 +312,6 @@ end describe '::cli' do - before do - # disable with_retries sleeping to [vastly] speed up testing - # - # we are relying the side effects of ::suitable? from a previous example - Retries.sleep_enabled = false - end - shared_examples 'uses default values' do it 'uses default values' do expect(described_class.superclass).to receive(:execute).with( @@ -400,8 +389,7 @@ url: 'http://localhost:111', ssh_private_key: 'cat.id_rsa', cli_username: 'myuser', - cli_tries: 222, - cli_try_sleep: 333 + cli_tries: 222 ) catalog.add_resource jenkins @@ -423,10 +411,8 @@ context 'without ssh_private_key' do CLI_AUTH_ERRORS.each do |error| it 'does not retry cli on AuthError exception' do - expect(described_class.superclass).to receive(:execute).with( - 'java -jar /usr/share/java/jenkins-cli.jar -s http://localhost:8080 -logger WARNING foo', - failonfail: true, combine: true - ).and_raise(AuthError, error) + expect(described_class).to receive(:execute_with_auth).once.and_raise(AuthError, error) + expect(Puppet::Util::RetryAction).not_to receive(:sleep) expect { described_class.cli('foo') }. to raise_error(AuthError) @@ -490,14 +476,12 @@ context 'network failure' do context 'without ssh_private_key' do CLI_NET_ERRORS.each do |error| - it 'does not retry cli on AuthError exception' do - expect(described_class.superclass).to receive(:execute).with( - 'java -jar /usr/share/java/jenkins-cli.jar -s http://localhost:8080 -logger WARNING foo', - failonfail: true, combine: true - ).exactly(30).times.and_raise(NetError, error) + it 'retries cli on NetError exception' do + expect(described_class).to receive(:execute_with_auth).exactly(31).times.and_raise(NetError, error) + expect(Puppet::Util::RetryAction).to receive(:sleep).exactly(30).times expect { described_class.cli('foo') }. - to raise_error(NetError) + to raise_error(Puppet::Util::RetryAction::RetryException::RetriesExceeded) end end end @@ -514,10 +498,7 @@ ) catalog.add_resource jenkins - expect(described_class.superclass).to receive(:execute).with( - 'java -jar /usr/share/java/jenkins-cli.jar -s http://localhost:8080 -logger WARNING foo', - failonfail: true, combine: true - ).exactly(30).times.and_raise(UnknownError, 'foo') + expect(Puppet::Util::RetryAction).to receive(:retry_action).with(retries: 30, retry_exceptions: [UnknownError, NetError]).and_raise(UnknownError, 'foo') expect { described_class.cli('foo', catalog: catalog) }. to raise_error(UnknownError, 'foo') @@ -530,10 +511,7 @@ ) catalog.add_resource jenkins - expect(described_class.superclass).to receive(:execute).with( - 'java -jar /usr/share/java/jenkins-cli.jar -s http://localhost:8080 -logger WARNING foo', - failonfail: true, combine: true - ).twice.and_raise(UnknownError, 'foo') + expect(Puppet::Util::RetryAction).to receive(:retry_action).with(retries: 2, retry_exceptions: [UnknownError, NetError]).and_raise(UnknownError, 'foo') expect { described_class.cli('foo', catalog: catalog) }. to raise_error(UnknownError, 'foo') @@ -547,10 +525,7 @@ ) catalog.add_resource jenkins - expect(described_class.superclass).to receive(:execute).with( - 'java -jar /usr/share/java/jenkins-cli.jar -s http://localhost:8080 -logger WARNING foo', - failonfail: true, combine: true - ).exactly(3).times.and_raise(UnknownError, 'foo') + expect(Puppet::Util::RetryAction).to receive(:retry_action).with(retries: 3, retry_exceptions: [UnknownError, NetError]).and_raise(UnknownError, 'foo') expect { described_class.cli('foo', catalog: catalog) }. to raise_error(UnknownError, 'foo') @@ -565,69 +540,12 @@ ) catalog.add_resource jenkins - expect(described_class.superclass).to receive(:execute).with( - 'java -jar /usr/share/java/jenkins-cli.jar -s http://localhost:8080 -logger WARNING foo', - failonfail: true, combine: true - ).twice.and_raise(UnknownError, 'foo') + expect(Puppet::Util::RetryAction).to receive(:retry_action).with(retries: 2, retry_exceptions: [UnknownError, NetError]).and_raise(UnknownError, 'foo') expect { described_class.cli('foo', catalog: catalog) }. to raise_error(UnknownError, 'foo') end end - - context 'waiting up to n seconds' do - # this isn't behavioral testing because we don't want to either wait - # for the wallclock delay timeout or attempt to accurate time examples - it 'by default' do - jenkins = Puppet::Type.type(:component).new( - name: 'jenkins::cli::config' - ) - catalog.add_resource jenkins - - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 2)) - - described_class.cli('foo', catalog: catalog) - end - - it 'from catalog value' do - jenkins = Puppet::Type.type(:component).new( - name: 'jenkins::cli::config', - cli_try_sleep: 3 - ) - catalog.add_resource jenkins - - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 3)) - - described_class.cli('foo', catalog: catalog) - end - - it 'from fact' do - Facter.add(:jenkins_cli_try_sleep) { setcode { 4 } } - - jenkins = Puppet::Type.type(:component).new( - name: 'jenkins::cli::config' - ) - catalog.add_resource jenkins - - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 4)) - - described_class.cli('foo', catalog: catalog) - end - - it 'from catalog overriding fact' do - Facter.add(:jenkins_cli_try_sleep) { setcode { 4 } } - - jenkins = Puppet::Type.type(:component).new( - name: 'jenkins::cli::config', - cli_try_sleep: 3 - ) - catalog.add_resource jenkins - - expect(described_class).to receive(:with_retries).with(hash_including(max_sleep_seconds: 3)) - - described_class.cli('foo', catalog: catalog) - end - end end context 'options with :stdinjson' do diff --git a/spec/unit/puppet/x/spec_jenkins_providers.rb b/spec/unit/puppet/x/spec_jenkins_providers.rb index 4e144433d..51a2701cf 100644 --- a/spec/unit/puppet/x/spec_jenkins_providers.rb +++ b/spec/unit/puppet/x/spec_jenkins_providers.rb @@ -8,19 +8,6 @@ described_class.confine_collection.instance_variable_get(:@confines) end - it 'has no matched confines' do - expect(described_class.confine_collection.summary).to eq({}) - end - - context 'feature :retries' do - it do - expect(confines).to include( - be_a(Puppet::Confine::Feature). - and(have_attributes(values: [:retries])) - ) - end - end - context 'commands :java' do it do expect(confines).to include(