Skip to content

Commit

Permalink
[JENKINS-38978] Eliminate usages of deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
marcrohlfs committed Jan 4, 2018
1 parent c68feda commit 2ba426f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
Expand Up @@ -26,7 +26,6 @@
import hudson.Extension;
import hudson.Util;
import hudson.cli.CLICommand;
import hudson.model.Hudson;
import hudson.model.ParameterValue;
import hudson.security.ACL;
import hudson.util.FormValidation;
Expand All @@ -49,6 +48,8 @@
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;

import jenkins.model.Jenkins;

import com.cloudbees.plugins.credentials.CredentialsMatcher;
import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;
Expand Down Expand Up @@ -409,7 +410,7 @@ private URLConnection prepareConnection(URL url) throws IOException {
@Override
protected UsernamePasswordCredentials findCredentialsByCredentialsId() {
List<UsernamePasswordCredentials> credentials =
CredentialsProvider.lookupCredentials(UsernamePasswordCredentials.class, Hudson.getInstance(), ACL.SYSTEM, new DomainRequirement());
CredentialsProvider.lookupCredentials(UsernamePasswordCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, new DomainRequirement());
CredentialsMatcher credentialsIdMatcher = CredentialsMatchers.withId(this.credentialsId);
return CredentialsMatchers.firstOrNull(credentials, credentialsIdMatcher);
}
Expand Down Expand Up @@ -460,7 +461,7 @@ public static class DescriptorImpl extends ParameterDescriptor {

public ListBoxModel doFillCredentialsIdItems() {
List<StandardCredentials> credentials =
CredentialsProvider.lookupCredentials(StandardCredentials.class, Hudson.getInstance(), ACL.SYSTEM, new DomainRequirement());
CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, new DomainRequirement());
CredentialsMatcher credentialsTypeMatcher = CredentialsMatchers.instanceOf(UsernamePasswordCredentials.class);
return new StandardListBoxModel().withEmptySelection().withMatching(credentialsTypeMatcher, credentials);
}
Expand Down
Expand Up @@ -23,14 +23,15 @@
*/
package eu.markov.jenkins.plugin.mvnmeta;

import hudson.model.Hudson;
import hudson.model.ParameterDefinition;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;

import jenkins.model.Jenkins;

import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.CredentialsStore;
Expand Down Expand Up @@ -104,7 +105,7 @@ private void migrateCredentials() throws IOException {
String description = "Generated credentials for " + customCredentialsId;
credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, customCredentialsId, description, this.username, this.password);

CredentialsStore credentialsStore = CredentialsProvider.lookupStores(Hudson.getInstance()).iterator().next();
CredentialsStore credentialsStore = CredentialsProvider.lookupStores(Jenkins.getInstance()).iterator().next();
credentialsStore.addCredentials(Domain.global(), credentials);
}

Expand Down
Expand Up @@ -24,8 +24,9 @@
package eu.markov.jenkins.plugin.mvnmeta;

import hudson.EnvVars;
import hudson.model.ParameterValue;
import hudson.model.AbstractBuild;
import hudson.model.ParameterValue;
import hudson.model.Run;
import hudson.util.VariableResolver;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -77,7 +78,7 @@ public MavenMetadataParameterValue(String name, String description, String group
}

@Override
public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) {
public void buildEnvironment(Run<?, ?> build, EnvVars env) {
env.put(getName() + GROUP_ID_SUFFIX, getGroupId());
env.put(getName() + ARTIFACT_ID_SUFFIX, getArtifactId());
env.put(getName() + VERSION_SUFFIX, getVersion());
Expand Down
Expand Up @@ -23,8 +23,8 @@
*/
package eu.markov.jenkins.plugin.mvnmeta;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import hudson.model.FreeStyleProject;
import hudson.model.ParametersDefinitionProperty;
Expand Down
@@ -1,6 +1,6 @@
package eu.markov.jenkins.plugin.mvnmeta;

import hudson.util.IOUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down

0 comments on commit 2ba426f

Please sign in to comment.