Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2010 JFrog Ltd.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.jfrog.hudson.maven3;
 
 
 import java.util.List;
 import java.util.Map;

Freestyle Maven 3 configurator. Currently for publishing only.

Author(s):
Noam Y. Tenne
 
 public class ArtifactoryMaven3Configurator extends BuildWrapper implements DeployerOverrider,
         BuildInfoAwareConfigurator {

    
Repository URL and repository to deploy artifacts to
 
     private final ServerDetails details;
     private final Credentials overridingDeployerCredentials;
    
If checked (default) deploy maven artifacts
 
     private final boolean deployArtifacts;
     private final IncludesExcludes artifactDeploymentPatterns;

    
Include environment variables in the generated build info
 
     private final boolean includeEnvVars;
 
     private final boolean deployBuildInfo;
     private final boolean runChecks;
 
     private final String violationRecipients;
 
     private final boolean includePublishArtifacts;
 
     private final String scopes;
 
     private boolean licenseAutoDiscovery;
     private boolean disableLicenseAutoDiscovery;
     private final boolean discardOldBuilds;
     private final boolean discardBuildArtifacts;
     private final String matrixParams;
     private final boolean enableIssueTrackerIntegration;
     private boolean aggregateBuildIssues;
     private String aggregationBuildStatus;
 
    public ArtifactoryMaven3Configurator(ServerDetails detailsCredentials overridingDeployerCredentials,
            IncludesExcludes artifactDeploymentPatternsboolean deployArtifactsboolean deployBuildInfo,
            boolean includeEnvVarsboolean runChecksString violationRecipientsboolean includePublishArtifacts,
            String scopesboolean disableLicenseAutoDiscoveryboolean discardOldBuilds,
            boolean discardBuildArtifactsString matrixParams,
            boolean enableIssueTrackerIntegrationboolean aggregateBuildIssuesString aggregationBuildStatus) {
        this. = details;
        this. = overridingDeployerCredentials;
        this. = artifactDeploymentPatterns;
        this. = runChecks;
        this. = violationRecipients;
        this. = includePublishArtifacts;
        this. = scopes;
        this. = discardOldBuilds;
        this. = discardBuildArtifacts;
        this. = matrixParams;
        this. = enableIssueTrackerIntegration;
        this. = aggregateBuildIssues;
        this. = aggregationBuildStatus;
        this. = !disableLicenseAutoDiscovery;
        this. = deployBuildInfo;
        this. = deployArtifacts;
        this. = includeEnvVars;
    }
    // NOTE: The following getters are used by jelly. Do not remove them
    public ServerDetails getDetails() {
        return ;
    }
    public boolean isDiscardOldBuilds() {
        return ;
    }
    public boolean isDiscardBuildArtifacts() {
        return ;
    }
    public boolean isOverridingDefaultDeployer() {
        return (getOverridingDeployerCredentials() != null);
    }
        return ;
    }
    public boolean isDeployArtifacts() {
        return ;
    }
    public String getMatrixParams() {
        return ;
    }
        return ;
    }
    public boolean isDeployBuildInfo() {
        return ;
    }
        for (ArtifactoryServer server : servers) {
            if (server.getName().equals(getArtifactoryName())) {
                return server;
            }
        }
        return null;
    }
    @SuppressWarnings({"UnusedDeclaration"})
    public String getRepositoryKey() {
        return  != null ? . : null;
    }
    public boolean isIncludePublishArtifacts() {
        return ;
    }

    

Returns:
The snapshots deployment repository. If not defined the releases deployment repository will be returned
    @SuppressWarnings({"UnusedDeclaration"})
    public String getSnapshotsRepositoryKey() {
        return  != null ?
                (. != null ? . : .) :
                null;
    }
    public boolean isLicenseAutoDiscovery() {
        return ;
    }
    public boolean isDisableLicenseAutoDiscovery() {
        return ;
    }
    public String getArtifactoryName() {
        return  != null ? . : null;
    }
    public String getScopes() {
        return ;
    }
    public boolean isIncludeEnvVars() {
        return ;
    }
    public String getViolationRecipients() {
        return ;
    }
    public boolean isRunChecks() {
        return ;
    }
    public boolean isEnableIssueTrackerIntegration() {
        return ;
    }
    public boolean isAggregateBuildIssues() {
        return ;
    }
    public String getAggregationBuildStatus() {
        return ;
    }
    public ArtifactoryServer getArtifactoryServer(String artifactoryServerName) {
        for (ArtifactoryServer server : servers) {
            if (server.getName().equals(artifactoryServerName)) {
                return server;
            }
        }
        return null;
    }
    @Override
    public Collection<? extends ActiongetProjectActions(AbstractProject project) {
        return ActionableHelper.getArtifactoryProjectAction(.project);
    }
    @Override
    public Environment setUp(final AbstractBuild buildLauncher launcherfinal BuildListener listener)
            throws IOExceptionInterruptedException {
        final String artifactoryServerName = getArtifactoryName();
        if (StringUtils.isBlank(artifactoryServerName)) {
            return super.setUp(buildlauncherlistener);
        }
        final ArtifactoryServer artifactoryServer = getArtifactoryServer(artifactoryServerName);
        if (artifactoryServer == null) {
            listener.getLogger().format("No Artifactory server configured for %s. " +
                    "Please check your configuration."artifactoryServerName).println();
            build.setResult(.);
            throw new IllegalArgumentException("No Artifactory server configured for " + artifactoryServerName);
        }
        final PublisherContext context = new PublisherContext.Builder().artifactoryServer(artifactoryServer)
                .violationRecipients(getViolationRecipients()).scopes(getScopes())
                        getAggregationBuildStatus()).build();
        build.setResult(.);
        return new Environment() {
            @Override
            public void buildEnvVars(Map<StringStringenv) {
                try {
                    ExtractorUtils.addBuilderInfoArguments(envbuildlistenercontextnull);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            @Override
            public boolean tearDown(AbstractBuild buildBuildListener listener) {
                Result result = build.getResult();
                if ( && result != null && result.isBetterOrEqualTo(.)) {
                    build.getActions().add(new BuildInfoResultAction(getArtifactoryName(), build));
                    build.getActions().add(new UnifiedPromoteBuildAction<ArtifactoryMaven3Configurator>(build,
                            ArtifactoryMaven3Configurator.this));
                }
                return true;
            }
        };
    }
    @Override
    public DescriptorImpl getDescriptor() {
        return (DescriptorImplsuper.getDescriptor();
    }
    @Extension(optional = true)
    public static class DescriptorImpl extends BuildWrapperDescriptor {
        public DescriptorImpl() {
            super(ArtifactoryMaven3Configurator.class);
            load();
        }
        @Override
        public boolean isApplicable(AbstractProject<?, ?> item) {
            return item.getClass().isAssignableFrom(FreeStyleProject.class);
        }
        @Override
        public String getDisplayName() {
            return "Maven3-Artifactory Integration";
        }
        @Override
        public boolean configure(StaplerRequest reqJSONObject jsonthrows FormException {
            req.bindParameters(this"maven3");
            save();
            return true;
        }
            return FormValidations.validateEmails(value);
        }

        
Returns the list of org.jfrog.hudson.ArtifactoryServer configured.

Returns:
can be empty but never null.
        public List<ArtifactoryServergetArtifactoryServers() {
            ArtifactoryBuilder.DescriptorImpl descriptor = (ArtifactoryBuilder.DescriptorImpl)
                    Hudson.getInstance().getDescriptor(ArtifactoryBuilder.class);
            return descriptor.getArtifactoryServers();
        }
        public boolean isJiraPluginEnabled() {
            return (Hudson.getInstance().getPlugin("jira") != null);
        }
    }

    
Convert any remaining local credential variables to a credentials object
    public static final class ConverterImpl extends OverridingDeployerCredentialsConverter {
        public ConverterImpl(XStream2 xstream) {
            super(xstream);
        }
    }

    

Deprecated:
Use org.jfrog.hudson.DeployerOverrider.getOverridingDeployerCredentials()
    @Deprecated
    private transient String username;

    

Deprecated:
Use org.jfrog.hudson.DeployerOverrider.getOverridingDeployerCredentials()
    @Deprecated
    private transient String scrambledPassword;

    

Deprecated:
Use org.jfrog.hudson.maven3.ArtifactoryMaven3Configurator.deployBuildInfo
    @Deprecated
    private transient boolean skipBuildInfoDeploy;
New to GrepCode? Check out our FAQ X