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

Provide proper plugin info for test runs #6

Open
bookwar opened this issue May 5, 2017 · 1 comment
Open

Provide proper plugin info for test runs #6

bookwar opened this issue May 5, 2017 · 1 comment

Comments

@bookwar
Copy link

bookwar commented May 5, 2017

JJB constructs different XML outputs based on plugin information provided to it.

Thus result you get by running test command with query_plugin_info=false parameter, is going to be different from the result you get on the properly set Jenkins Master.

We need to add a reference plugin information, and test our configs against it.

@bookwar
Copy link
Author

bookwar commented May 22, 2017

For test runs JJB can use a yaml file instead of connection to Jenkins via

jenkins-jobs --conf example.conf test -p plugin_info.yaml jobs/

Yaml needs to be in the form:

- description-setter:
    shortName: description-setter
    longName: Description Setter Plugin
    version: 1.2.3

To get such a yaml from existing Jenkins instance one can use script like this:

#!/usr/bin/env python

import argparse
import ConfigParser
import jenkins
import yaml

parser = argparse.ArgumentParser()
parser.add_argument("-c", "--conf", required=True,
                    help="Path to jenkins-job-builder config file")
args = parser.parse_args()

config = ConfigParser.RawConfigParser()
config.read(args.conf)

jenkinsurl = config.get('jenkins', 'url')
username = config.get('jenkins', 'user')
password = config.get('jenkins', 'password')

j = jenkins.Jenkins(jenkinsurl, username, password)

data = j.get_plugins()
plugin_info = []

for shortName, longName in data.keys():
    plugin_info.append({
        shortName: {
            'longName': longName,
            'shortName': shortName,
            'version': "{0}".format(data[shortName]['version']),
        }
    })
    

with open('plugins_info.yaml','w') as f:
    f.write(yaml.dump(plugin_info, default_flow_style=False))

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

No branches or pull requests

1 participant