Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2011 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.ivy;
 
 import  org.jfrog.build.extractor.listener.ArtifactoryBuildListener;
 
 import java.io.File;
 import java.util.List;
 import java.util.Map;


Gradle-Artifactory plugin configuration, allows to add the server details, deployment username/password, as well as flags to deploy ivy, maven, and artifacts, as well as specifications of the location of the remote plugin (.gradle) groovy script.

Author(s):
Tomer Cohen
 
         BuildInfoAwareConfigurator {
 
     private ServerDetails details;
     private boolean deployArtifacts;
     private final Credentials overridingDeployerCredentials;
     public final String remotePluginLocation;
     public final boolean deployBuildInfo;
     public final boolean includeEnvVars;
     private final boolean runChecks;
     private final String violationRecipients;
     private final boolean includePublishArtifacts;
     private final String scopes;
     private final boolean licenseAutoDiscovery;
     private final boolean disableLicenseAutoDiscovery;
     private final String ivyPattern;
     private String aggregationBuildStatus;
     private final String artifactPattern;
     private final boolean notM2Compatible;
     private final boolean discardOldBuilds;
     private final boolean passIdentifiedDownstream;
     private final boolean discardBuildArtifacts;
     private final String matrixParams;
     private final boolean enableIssueTrackerIntegration;
     private boolean aggregateBuildIssues;
    public ArtifactoryIvyFreeStyleConfigurator(ServerDetails detailsCredentials overridingDeployerCredentials,
            boolean deployArtifactsString remotePluginLocation,
            boolean includeEnvVarsboolean deployBuildInfoboolean runChecksString violationRecipients,
            boolean includePublishArtifactsString scopesboolean disableLicenseAutoDiscoveryString ivyPattern,
            String artifactPatternboolean notM2CompatibleIncludesExcludes artifactDeploymentPatterns,
            boolean discardOldBuildsboolean passIdentifiedDownstreamboolean discardBuildArtifacts,
            String matrixParamsboolean enableIssueTrackerIntegrationboolean aggregateBuildIssues,
            String aggregationBuildStatus) {
        this. = details;
        this. = overridingDeployerCredentials;
        this. = deployArtifacts;
        this. = remotePluginLocation;
        this. = includeEnvVars;
        this. = deployBuildInfo;
        this. = runChecks;
        this. = violationRecipients;
        this. = includePublishArtifacts;
        this. = scopes;
        this. = disableLicenseAutoDiscovery;
        this. = ivyPattern;
        this. = aggregationBuildStatus;
        this. = clearApostrophes(artifactPattern);
        this. = notM2Compatible;
        this. = artifactDeploymentPatterns;
        this. = discardOldBuilds;
        this. = passIdentifiedDownstream;
        this. = matrixParams;
        this. = enableIssueTrackerIntegration;
        this. = aggregateBuildIssues;
        this. = !disableLicenseAutoDiscovery;
        this. = discardBuildArtifacts;
    }

    
Clears the extra apostrophes from the start and the end of the string
    private String clearApostrophes(String artifactPattern) {
        return StringUtils.removeEnd(StringUtils.removeStart(artifactPattern"\""), "\"");
    }
    public ServerDetails getDetails() {
        return ;
    }
    public String getMatrixParams() {
        return ;
    }
    public boolean isPassIdentifiedDownstream() {
        return ;
    }
    public boolean isDiscardBuildArtifacts() {
        return ;
    }
    public boolean isDiscardOldBuilds() {
        return ;
    }
    public boolean isOverridingDefaultDeployer() {
        return (getOverridingDeployerCredentials() != null);
    }
        return ;
    }
    public String getViolationRecipients() {
        return ;
    }
    public String getArtifactPattern() {
        return clearApostrophes();
    }
    public String getIvyPattern() {
        return ;
    }
        return ;
    }
    public boolean isRunChecks() {
        return ;
    }
    public boolean isIncludePublishArtifacts() {
        return ;
    }
    public boolean isDeployBuildInfo() {
        return ;
    }
    public boolean isLicenseAutoDiscovery() {
        return ;
    }
    public boolean isDisableLicenseAutoDiscovery() {
        return ;
    }
    public String getScopes() {
        return ;
    }
    public boolean isIncludeEnvVars() {
        return ;
    }
    public String getRepositoryKey() {
        return  != null ? . : null;
    }
    public String getArtifactoryName() {
        return  != null ? . : null;
    }
    public boolean isDeployArtifacts() {
        return ;
    }
    public boolean isNotM2Compatible() {
        return ;
    }
    public boolean isM2Compatible() {
        return !;
    }
    public boolean isEnableIssueTrackerIntegration() {
        return ;
    }
    public boolean isAggregateBuildIssues() {
        return ;
    }
    public String getAggregationBuildStatus() {
        return ;
    }
    @Override
    public Collection<? extends ActiongetProjectActions(AbstractProject project) {
        return ActionableHelper.getArtifactoryProjectAction(.project);
    }
    @Override
    public Environment setUp(final AbstractBuild buildLauncher launcherfinal BuildListener listener)
            throws IOExceptionInterruptedException {
                .violationRecipients(getViolationRecipients()).scopes(getScopes())
                        getAggregationBuildStatus()).build();
        File localDependencyFile = Which.jarFile(ArtifactoryBuildListener.class);
        final FilePath actualDependencyDir =
                PluginDependencyHelper.getActualDependencyDirectory(buildlocalDependencyFile);
        final Ant builder = getLastAntBuild(build.getProject());
        String originalTargets = null;
        if (builder != null) {
            originalTargets = builder.getTargets();
            setTargetsField(builderoriginalTargets + " " + getAdditionalAntArgs(actualDependencyDir));
        }
        build.setResult(.);
        final String finalOriginalTargets = originalTargets;
        return new Environment() {
            @Override
            public void buildEnvVars(Map<StringStringenv) {
                super.buildEnvVars(env);
                try {
                    ExtractorUtils.addBuilderInfoArguments(envbuildlistenercontextnull);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            @Override
            public boolean tearDown(AbstractBuild buildBuildListener listener)
                    throws IOExceptionInterruptedException {
                if (builder != null) {
                    setTargetsField(builderfinalOriginalTargets);
                }
                Result result = build.getResult();
                if (!context.isSkipBuildInfoDeploy() && (result == null || result.isBetterOrEqualTo(.))) {
                    build.getActions().add(0, new BuildInfoResultAction(context.getArtifactoryName(), build));
                    build.getActions().add(new UnifiedPromoteBuildAction<ArtifactoryIvyFreeStyleConfigurator>(build,
                            ArtifactoryIvyFreeStyleConfigurator.this));
                }
                return true;
            }
        };
    }
    private void setTargetsField(Ant builderString targets) {
        try {
            Field targetsField = builder.getClass().getDeclaredField("targets");
            targetsField.setAccessible(true);
            targetsField.set(buildertargets);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    // this is blech.
    private String getAdditionalAntArgs(FilePath actualDependencyDir) {
        StringBuilder targets = new StringBuilder();
        String actualDependencyDirPath = actualDependencyDir.getRemote();
        actualDependencyDirPath = actualDependencyDirPath.replace('\\''/');
        actualDependencyDirPath = "\"" + actualDependencyDirPath + "\"";
        targets.append("-lib ").append(actualDependencyDirPath).append(" ");
        targets.append("-listener ").append("org.jfrog.build.extractor.listener.ArtifactoryBuildListener")
                .append(" ");
        return targets.toString();
    }
    private Ant getLastAntBuild(AbstractProject project) {
        if (project instanceof Project) {
            List<Antants = ActionableHelper.getBuilder((ProjectprojectAnt.class);
            return Iterables.getLast(antsnull);
        }
        return null;
    }
        for (ArtifactoryServer server : servers) {
            if (server.getName().equals(getArtifactoryName())) {
                return server;
            }
        }
        return null;
    }
    @Override
    public DescriptorImpl getDescriptor() {
        return (DescriptorImplsuper.getDescriptor();
    }
    @Extension(optional = true)
    public static class DescriptorImpl extends BuildWrapperDescriptor {
        public DescriptorImpl() {
            super(ArtifactoryIvyFreeStyleConfigurator.class);
            load();
        }
        @Override
        public boolean isApplicable(AbstractProject<?, ?> item) {
            return item.getClass().isAssignableFrom(FreeStyleProject.class);
        }
        @Override
        public String getDisplayName() {
            return "Ant/Ivy-Artifactory Integration";
        }
        @Override
        public boolean configure(StaplerRequest reqJSONObject jsonthrows FormException {
            req.bindParameters(this"ivy");
            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;
New to GrepCode? Check out our FAQ X