Search in sources :

Example 1 with ArtifactResolverUtil

use of org.jenkinsci.test.acceptance.utils.aether.ArtifactResolverUtil in project acceptance-test-harness by jenkinsci.

the class FallbackConfig method getJenkinsWar.

/**
 * Get the file with Jenkins to run.
 *
 * The file will exist on machine where tests run.
 */
@Provides
@Named("jenkins.war")
public File getJenkinsWar(RepositorySystem repositorySystem, RepositorySystemSession repositorySystemSession) {
    try {
        return IOUtil.firstExisting(false, System.getenv("JENKINS_WAR"));
    } catch (IOException ex) {
    }
    String version = System.getenv("JENKINS_VERSION");
    if (version != null && !version.isEmpty()) {
        ArtifactResolverUtil resolverUtil = new ArtifactResolverUtil(repositorySystem, repositorySystemSession);
        ArtifactResult resolvedArtifact = resolverUtil.resolve(new DefaultArtifact("org.jenkins-ci.main", "jenkins-war", "war", version));
        return resolvedArtifact.getArtifact().getFile();
    }
    try {
        // Lowest priority of all
        return IOUtil.firstExisting(false, System.getenv("JENKINS_WAR"), getWorkspace() + "/jenkins.war", "./jenkins.war");
    } catch (IOException ex) {
        throw new Error("Could not find jenkins.war, use JENKINS_WAR or JENKINS_VERSION to specify it.", ex);
    }
}
Also used : IOException(java.io.IOException) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResolverUtil(org.jenkinsci.test.acceptance.utils.aether.ArtifactResolverUtil) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) Named(javax.inject.Named) Provides(com.google.inject.Provides)

Example 2 with ArtifactResolverUtil

use of org.jenkinsci.test.acceptance.utils.aether.ArtifactResolverUtil in project acceptance-test-harness by jenkinsci.

the class FallbackConfig method getFormElementsPathFile.

/**
 * Provides the path to the form elements plug-in. Uses the Maven repository to obtain the plugin.
 *
 * @return the path to the form elements plug-in
 */
@Named("form-element-path.hpi")
@Provides
public File getFormElementsPathFile(RepositorySystem repositorySystem, RepositorySystemSession repositorySystemSession) {
    ArtifactResolverUtil resolverUtil = new ArtifactResolverUtil(repositorySystem, repositorySystemSession);
    String version = System.getenv("FORM_ELEMENT_PATH_VERSION");
    version = version == null ? "1.12" : version;
    ArtifactResult resolvedArtifact = resolverUtil.resolve(new DefaultArtifact("org.jenkins-ci.plugins", "form-element-path", "hpi", version));
    return resolvedArtifact.getArtifact().getFile();
}
Also used : DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResolverUtil(org.jenkinsci.test.acceptance.utils.aether.ArtifactResolverUtil) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) Named(javax.inject.Named) Provides(com.google.inject.Provides)

Example 3 with ArtifactResolverUtil

use of org.jenkinsci.test.acceptance.utils.aether.ArtifactResolverUtil in project acceptance-test-harness by jenkinsci.

the class PluginMetadata method resolve.

public File resolve(Injector i, String version) {
    DefaultArtifact artifact = getDefaultArtifact();
    if (version != null) {
        artifact.setVersion(version);
    }
    ArtifactResolverUtil resolverUtil = i.getInstance(ArtifactResolverUtil.class);
    ArtifactResult r = resolverUtil.resolve(artifact);
    return r.getArtifact().getFile();
}
Also used : DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResolverUtil(org.jenkinsci.test.acceptance.utils.aether.ArtifactResolverUtil) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Aggregations

DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)3 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)3 ArtifactResolverUtil (org.jenkinsci.test.acceptance.utils.aether.ArtifactResolverUtil)3 Provides (com.google.inject.Provides)2 Named (javax.inject.Named)2 IOException (java.io.IOException)1