Improved artifactory servers control
Change-Id: I58ab40003da3569742ebb9316be152a0fbf089d8
diff --git a/_states/jenkins_artifactory.py b/_states/jenkins_artifactory.py
index 7683cd7..63a63d6 100644
--- a/_states/jenkins_artifactory.py
+++ b/_states/jenkins_artifactory.py
@@ -7,6 +7,7 @@
import org.jfrog.hudson.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("org.jfrog.hudson.ArtifactoryBuilder")
+// empty artifactory servers is not empty list but null, but find can be called on null
def server = desc.getArtifactoryServers().find{{it -> it.name.equals("{name}")}}
if(server &&
server.getName().equals("{name}") &&
@@ -15,8 +16,11 @@
server.getResolverCredentialsConfig().getCredentialsId().equals("{credentialsId}")){{
print("EXISTS")
}}else{{
+ // we must care about null here
if(desc.getArtifactoryServers() != null && !desc.getArtifactoryServers().isEmpty()){{
desc.getArtifactoryServers().removeIf{{it -> it.name.equals("{name}")}}
+ }}else{{
+ desc.setArtifactoryServers([])
}}
def newServer = new ArtifactoryServer(
"{name}",