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

Issue when Jenkins installed in a non-root URL #13

Closed
emilioestebanez opened this issue Nov 15, 2016 · 3 comments
Closed

Issue when Jenkins installed in a non-root URL #13

emilioestebanez opened this issue Nov 15, 2016 · 3 comments

Comments

@emilioestebanez
Copy link

emilioestebanez commented Nov 15, 2016

Good afternoon,

I'm trying to use your plugin to get a backup of the Jenkins jobs in my installation. However, I'm facing an issue because my Jenkins is installed in http://localhost:8080/jenkins/ (and not on http://localhost:8080).

What happens is that it retrieves all the jobs correctly, but when trying to retrieve each job individually it constructs the URLs like this:
http://localhost:8080/jenkins//jenkins/job/Test-A-Config/config.xml

instead of
http://localhost:8080/jenkins/job/Test-A-Config/config.xml

I've seen how to fix it:
In jenkinsServer.js, line 50 I've replaced this

var path = j.url.replace(/^https?\:\/{2}[^\/]+\/(.*)/, '$1');
var url = [serverUrl, path].join('/');

with:

var path = j.url.replace(/^https?\:\/{2}[^\/]+\/(.*)/, '$1');
var serverHost = serverUrl.replace(/^(https?\:\/{2}[^\/]+)\/(.*)/, '$1');
var url = [serverHost, path].join('/');

Would it be possible for you to add this fix (or a similar one of your liking) to your published code? Because I have it running locally with the fix I mentioned above, but I'm planning to use it from the Jenkins server itself in which I don't have access to modify the jenkinsServer.js.

Thank you!

Best regards,
Emilio

@sghill
Copy link
Owner

sghill commented Nov 21, 2016

Thanks for the report! As of 494dfc6, released as v0.8.0, this should just work with a context root. Would you mind giving it a try and reporting back?

For context, the regex replacement was introduced in #9. I think this is a relatively rare use-case, so it's now opt-in and by default we'll simply use the job urls returned by the Jenkins API.

@emilioestebanez
Copy link
Author

Works perfectly. Thank you very much!

@sghill
Copy link
Owner

sghill commented Nov 21, 2016

That's great, thanks for the followup!

@sghill sghill closed this as completed Nov 21, 2016
This issue was closed.
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