Skip to content

withCredentials and usernamePassword Binder no longer works #320

@fnobilia

Description

@fnobilia

Hi there!

In my code, I've something like that

withCredentials([usernamePassword(
            credentialsId: github_credentials_id,
            passwordVariable: 'GITHUB_PASSWORD',
            usernameVariable: 'GITHUB_USER')
    ]) {
        sh(script: """
            #!/bin/bash
            git clone --single-branch --branch master https://\$GITHUB_USER:\$GITHUB_PASSWORD@github.com/<REPO-NAME>.git <REPO-BRANCH>
        )
    }

I'm using JenkinsPipelineUnit to test my custom groovy functions. Tests are passing fine when running with JenkinsPipelineUnit up to v1.3.

Starting from v1.4, tests are failing with the following errors

groovy.lang.MissingMethodException: 
No signature of method: groovy.lang.Binding.setVariable() is applicable for argument types: (LinkedHashMap, String) values: [[credentialsId:<ID>, passwordVariable:GITHUB_PASSWORD, ...], ...]
Possible solutions: getVariable(java.lang.String), setVariable(java.lang.String, java.lang.Object), getVariables(), hasVariable(java.lang.String)
        at xxx.groovy:40)

for v1.4 and v1.5. While starting from v1.6

groovy.lang.MissingMethodException: 
No signature of method: groovy.lang.Binding.setVariable() is applicable for argument types: (ArrayList, String) values: [[GITHUB_USER, GITHUB_PASSWORD], USERNAME:PASSWORD]
Possible solutions: getVariable(java.lang.String), setVariable(java.lang.String, java.lang.Object), getVariables(), hasVariable(java.lang.String)
        at xxx.groovy:58)

I checked credentials-binding the documentation, and my code seems ok.

Do you have any suggestion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions