Skip to content
Permalink
Browse files

[JENKINS-38978] Eliminate usages of deprecated API

  • Loading branch information
marcrohlfs committed Jan 4, 2018
1 parent c68feda commit 2ba426f0fb442192b9e875b6fcf09f9af506583c
@@ -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;
@@ -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;
@@ -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);
}
@@ -460,7 +461,7 @@ private SortOrder(String displayName) {

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);
}
@@ -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;
@@ -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);
}

@@ -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;
@@ -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());
@@ -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;
@@ -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;

0 comments on commit 2ba426f

Please sign in to comment.
You can’t perform that action at this time.