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

I need the API to create view #20

Open
liweing opened this issue Oct 8, 2012 · 4 comments
Open

I need the API to create view #20

liweing opened this issue Oct 8, 2012 · 4 comments

Comments

@liweing
Copy link

liweing commented Oct 8, 2012

can you please provide the API to create View for Pipeline view?

@srogier
Copy link
Member

srogier commented Oct 8, 2012

jenkins-php-api is an Jenkins Api client for php. We only retrieve information provided by Jenkins server.

So, if if's not in the Jenkins API, it won't be in jenkins-php-api.

@liweing
Copy link
Author

liweing commented Oct 8, 2012

Jenkins has the API, below is the python client code of Jenkins API :

def create_view(self, str_view_name, people=None):
"""
Create a view, viewExistsCheck
:param str_view_name: name of new view, str
:return: new view obj
"""

    if people:
        url = "%s/user/%s/my-views" %(self.baseurl, people)
    else:
        url = self.baseurl
    viewExistsCheck_url = "%s/viewExistsCheck?value=%s" %(url, str_view_name)
    fn_urlopen = self.get_jenkins_obj().get_opener()
    try:
        r = fn_urlopen(viewExistsCheck_url).read()
    except urllib2.HTTPError, e:
        log.debug("Error reading %s" % url)
        log.exception(e)
        raise
    """<div/>"""
    if len(r) > 7: 
        return 'A view already exists with the name "%s"' % (str_view_name)
    else:
        data = {"mode":"hudson.model.ListView", "Submit": "OK"}
        data['name']=str_view_name
        data['json'] = data.copy()
        params = urllib.urlencode(data)
        try:
            result = self.post_data('%s/createView' % url, params)
        except urllib2.HTTPError, e:
            log.debug("Error post_data %s" % url)
            log.exception(e)
        return url

@agallou
Copy link
Member

agallou commented Oct 8, 2012

this could be done by calling the execute method

https://github.com/pmsipilot/jenkins-php-api/blob/master/Jenkins.php#L627

with "createView" as first parameter and the same parameters than data of your example in the second parameter.

@liweing
Copy link
Author

liweing commented Oct 8, 2012

ok, let me have a try! thanks for your reply.

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

3 participants