In my plugin, I got access to the Artifactory Credentials system configuration. 1) add artifactory dependency to pom.xml. i.e.
<dependency> <groupId>org.jenkins-ci.plugins</groupId> <artifactId>artifactory</artifactId> <version>2.9.0</version> <type>jar</type> </dependency>
2) find the exact configuration global.jelly config. I found in org.jfrog.hudson.ArtifactoryBuilder
<table style="width: 100%" id="legacyDeployerCredentials${server.url}"> <f:entry title="Username" help="/plugin/artifactory/help/common/help-deployerUserName.html"> <f:textbox name="username" field="username" value="${server.deployerCredentialsConfig.username}"/> </f:entry> <f:entry title="Password" help="/plugin/artifactory/help/common/help-deployerPassword.html"> <f:password name="password" field="password" value="${server.deployerCredentialsConfig.password}"/> </f:entry> </table> </f:block> </f:section>
3) define the class used to apply the configuration. org.jfrog.hudson.ArtifactoryBuilder.java 4) create an instance of jenkins and access the plugin descriptor, get user credentials.
ArtifactoryBuilder.DescriptorImpl ab = (ArtifactoryBuilder.DescriptorImpl) jenkins.model.Jenkins.getInstance().getDescriptor(ArtifactoryBuilder.class); ArtifactoryServer server = ab.getArtifactoryServers().iterator().next(); this.userName = server.getDeployerCredentialsConfig().getUsername(); this.password = server.getDeployerCredentialsConfig().getPassword();
Mayur lokare
source share