ARTIFACTORY: How to resolve Jenkins Artifactory plugin error “java.lang.ArrayIndexOutOfBoundsException“

ARTIFACTORY: How to resolve Jenkins Artifactory plugin error “java.lang.ArrayIndexOutOfBoundsException“

AuthorFullName__c
Shisiya Sebastian
articleNumber
000006206
ft:sourceType
Salesforce
FirstPublishedDate
2024-10-21T10:00:29Z
lastModifiedDate
2024-10-21
VersionNumber
3
Issue

If errors like the following appear in the Jenkins pipeline logs, they are related to the credentials configured for the corresponding job.

java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
    at org.jfrog.hudson.util.Credentials.extractUsernameFromToken(Credentials.java:65)
    at org.jfrog.hudson.util.Credentials.convertAccessTokenToUsernamePassword(Credentials.java:89)
    at org.jfrog.hudson.util.ExtractorUtils.setPublisherInfo(ExtractorUtils.java:433)
    at org.jfrog.hudson.util.ExtractorUtils.setPublisherResolverInfo(ExtractorUtils.java:265)



Cause

If you encounter these errors with any Artifactory server configured via the Artifactory plugin, it means that the Jenkins task is unable to use the access token set up for authentication with the Artifactory server.


Solution

There are two approaches to resolve the issue when configuring the credentials:
1.Using the username and access token 

2. Using the username and password

To configure the Credentials in Jenkins:


1. Jenkins → Manage Jenkins → Manage Credentials → System → Global Credentials → Add Credentials

2. Choose “Username with password” in the credentials Kind field
3. Copy and paste the Access Token/password  to the Password field and Create

 

 

Recommendations


If you're currently using the Artifactory Plugin, we recommend installing the JFrog Plugin as well and gradually migrating your jobs from the old plugin to the new one. The Artifactory Plugin is older, while the JFrog Plugin includes more enhancements and is based on JFrog CLI v2.

 

References


Access Token in Jenkins
Jenkins Artifactory Plugin