Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXES JENKINS-30223] return back com.cloudbees.jenkins.Credential
as of it makes fail to boot jenkins after installation of plugin which depends on this class. Also remove migration to another package for this class and use it directly
- Loading branch information
Showing
6 changed files
with
79 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.cloudbees.jenkins; | ||
|
||
import com.google.common.base.Predicate; | ||
import com.google.common.base.Predicates; | ||
import org.jenkinsci.plugins.github.GitHubPlugin; | ||
import org.jenkinsci.plugins.github.config.GitHubServerConfig; | ||
import org.kohsuke.github.GitHub; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.CheckForNull; | ||
import java.io.IOException; | ||
|
||
import static org.jenkinsci.plugins.github.util.FluentIterableWrapper.from; | ||
|
||
/** | ||
* Credential to access GitHub. | ||
* Used only for migration. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
* @see org.jenkinsci.plugins.github.config.GitHubPluginConfig | ||
* @see GitHubServerConfig | ||
* @deprecated since 1.13.0 plugin uses credentials-plugin to manage tokens. All configuration moved to | ||
* {@link org.jenkinsci.plugins.github.config.GitHubPluginConfig} which can be fetched via | ||
* {@link GitHubPlugin#configuration()}. You can fetch corresponding config with creds by | ||
* {@link org.jenkinsci.plugins.github.config.GitHubPluginConfig#findGithubConfig(Predicate)} which returns | ||
* iterable over authorized nonnull {@link GitHub}s matched your predicate | ||
*/ | ||
@Deprecated | ||
public class Credential { | ||
@SuppressWarnings("visibilitymodifier") | ||
public final transient String username; | ||
@SuppressWarnings("visibilitymodifier") | ||
public final transient String apiUrl; | ||
@SuppressWarnings("visibilitymodifier") | ||
public final transient String oauthAccessToken; | ||
|
||
@DataBoundConstructor | ||
public Credential(String username, String apiUrl, String oauthAccessToken) { | ||
this.username = username; | ||
this.apiUrl = apiUrl; | ||
this.oauthAccessToken = oauthAccessToken; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public String getApiUrl() { | ||
return apiUrl; | ||
} | ||
|
||
public String getOauthAccessToken() { | ||
return oauthAccessToken; | ||
} | ||
|
||
/** | ||
* @return authorized first {@link GitHub} from global config or null if no any | ||
* @throws IOException never thrown, but in signature for backward compatibility | ||
* @deprecated see class javadoc. Now any instance return same GH. Please use new api to fetch another | ||
*/ | ||
@CheckForNull | ||
@Deprecated | ||
public GitHub login() throws IOException { | ||
return from(GitHubPlugin.configuration().findGithubConfig(Predicates.<GitHubServerConfig>alwaysTrue())) | ||
.first().orNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/main/java/org/jenkinsci/plugins/github/deprecated/Credential.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/java/org/jenkinsci/plugins/github/migration/MigratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters