Skip to content

Instantly share code, notes, and snippets.

@lanwen
Last active November 23, 2015 13:40
Show Gist options
  • Save lanwen/553b51c9d2227eaad435 to your computer and use it in GitHub Desktop.
Save lanwen/553b51c9d2227eaad435 to your computer and use it in GitHub Desktop.
@Extension
public class TrekClientDescriptor extends GlobalConfiguration implements Module {
private TrackerClientConfig config = TrackerClientConfig.empty();
public TrekClientDescriptor() {
load();
}
@Override
public void configure(Binder binder) {
binder.bind(TrackerClient.class).to(TrekClientImpl.class);
}
@Provides
public TrekClientImpl getClient() {
return new TrekClientImpl(String.valueOf(config.getApiUrl()), tokenFrom(config.getCredentialsId()));
}
}
public class IssueUpdater extends Recorder {
@DataBoundConstructor
public IssueUpdater() {
}
@Inject
private TrackerClient client;
@Override
public boolean perform(final AbstractBuild build, final Launcher launcher, final BuildListener listener) {
// at this moment - client = null;
// If i do Jenkins.getInstance().getInjector().injectMembers(this); - all ok
// ...
return true;
}
}
public class TrekClientImpl implements TrackerClient {
@Inject
public TrekClientImpl(String apiUrl, String apiToken) {
// some logic with url and token
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment