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

Triggering Jenkins Build from Perl #20

Open
ghost opened this issue Mar 6, 2018 · 2 comments
Open

Triggering Jenkins Build from Perl #20

ghost opened this issue Mar 6, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 6, 2018

Hi,
I was able to trigger the jenkins build using perl earlier. But Now I have latest version of jenkins and I am trying to trigger the jenkins job using perl. But I am getting authentication failure output when I print the code.

Below is my code.

my $JOB = Jenkins::API->new({base_url => 'Jenkins_url', api_key => 'Jenkins_USER', api_pass => 'Jenkins_PASSWORD'});

	my$test = $JOB ->check_jenkins_url;
	
	print "Jenkins URL : $test \n\n";
    my $BUILD = $JOB->trigger_build('JOBNAME');
	
	unless($BUILD)
{
    if($JOB3->response_code == 403)
    {
        print "Auth failure\n";
    }
    else
    {
        print $JOB3->response_content;
    }
}

Can you please advice me on this?

@ghost ghost closed this as completed Mar 6, 2018
@ghost ghost reopened this Mar 6, 2018
@metaphox
Copy link

I think the 403 is caused by crumb for CSRF Protection, and this wrapper is not being updated. You can either turn off the CSRF in Jenkins settings (it's on by default), or just use REST to add the crumb by yourself.

@colinnewell
Copy link
Owner

It would be neat to add that to the library, I'm afraid I just haven't had the tuit's to do it recently.

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

2 participants