-
-
Notifications
You must be signed in to change notification settings - Fork 107
Fix Jenkins.instance is missing #149
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
Conversation
jakub-bochenski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except it seems there are some random imports in LogstashConfiguration.java
Can you please remove them?
Also can you please restore the previous state after setting LogstashConfiguration.getInstance().setEnableGlobally(true);
|
Thanks for the PR |
|
We are running the artifact build from this PR in our Jenkins and can I confirm the issue is fixed without any other errors coming up |
|
@Seros great, thanks! |
|
Hmm I see there are some conflicts now, that's a bit strange. Can you please rebase it on latest master? |
|
I don't see any conflicts and the branch is up-to-date |
|
That's weird, GH tells me |
According to the [doc][1] to get an instance of a config we should use `ExtensionList.lookupSingleton(<your GlobalConfiguration subclass>.class)` Added additional test to handle a remote logging from workflow pipeline job. Initially started to check the code because we got exceptions on agents when using Git checkout: ``` java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong. at jenkins.model.Jenkins.get(Jenkins.java:816) at jenkins.model.GlobalConfiguration.all(GlobalConfiguration.java:75) at jenkins.plugins.logstash.LogstashConfiguration.getInstance(LogstashConfiguration.java:289) at jenkins.plugins.logstash.LogstashWriter.getIndexerDao(LogstashWriter.java:162) at jenkins.plugins.logstash.LogstashWriter.getDaoOrNull(LogstashWriter.java:201) at jenkins.plugins.logstash.LogstashWriter.<init>(LogstashWriter.java:82) at jenkins.plugins.logstash.pipeline.GlobalDecorator.decorate(GlobalDecorator.java:41) at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator.decorateAll(TaskListenerDecorator.java:230) at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator$DecoratedTaskListener.getOutputStream(TaskListenerDecorator.java:267) at org.jenkinsci.plugins.workflow.log.OutputStreamTaskListener$Default.getLogger(OutputStreamTaskListener.java:116) at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator$CloseableTaskListener.getLogger(TaskListenerDecorator.java:307) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2801) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2762) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2757) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2051) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2063) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:1115) at hudson.plugins.git.GitAPI.revParse(GitAPI.java:419) ``` [1]: https://javadoc.jenkins-ci.org/jenkins/model/GlobalConfiguration.html
According to the [doc][1] to get an instance of a config we should use `ExtensionList.lookupSingleton(<your GlobalConfiguration subclass>.class)` Added additional test to handle a remote logging from workflow pipeline job. Initially started to check the code because we got exceptions on agents when using Git checkout: ``` java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong. at jenkins.model.Jenkins.get(Jenkins.java:816) at jenkins.model.GlobalConfiguration.all(GlobalConfiguration.java:75) at jenkins.plugins.logstash.LogstashConfiguration.getInstance(LogstashConfiguration.java:289) at jenkins.plugins.logstash.LogstashWriter.getIndexerDao(LogstashWriter.java:162) at jenkins.plugins.logstash.LogstashWriter.getDaoOrNull(LogstashWriter.java:201) at jenkins.plugins.logstash.LogstashWriter.<init>(LogstashWriter.java:82) at jenkins.plugins.logstash.pipeline.GlobalDecorator.decorate(GlobalDecorator.java:41) at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator.decorateAll(TaskListenerDecorator.java:230) at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator$DecoratedTaskListener.getOutputStream(TaskListenerDecorator.java:267) at org.jenkinsci.plugins.workflow.log.OutputStreamTaskListener$Default.getLogger(OutputStreamTaskListener.java:116) at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator$CloseableTaskListener.getLogger(TaskListenerDecorator.java:307) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2801) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2762) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2757) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2051) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2063) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:1115) at hudson.plugins.git.GitAPI.revParse(GitAPI.java:419) ``` `getIndexerDao` should return `null` if configuration isn't yet available. In that case `getDaoOrNull` will return `null` as it is expected. [1]: https://javadoc.jenkins-ci.org/jenkins/model/GlobalConfiguration.html
fbc6997 to
6f83856
Compare
|
Sorry for some reason my git behaved weird. Now the rebase worked |
|
Alright, thanks again. I think automatic releases should pick this up. |
Merges #138, #147 and salemove#1 to fix https://issues.jenkins.io/browse/JENKINS-71693
Testing done
Submitter checklist