[JIRA] (JENKINS-60352) Ansible Tower Plugin does not pass credentials from job to Ansible tower 3.6.1

17 views
Skip to first unread message

vivchebolu@gmail.com (JIRA)

unread,
Dec 3, 2019, 9:51:02 AM12/3/19
to jenkinsc...@googlegroups.com
Viv Cheolu created an issue
 
Jenkins / Bug JENKINS-60352
Ansible Tower Plugin does not pass credentials from job to Ansible tower 3.6.1
Issue Type: Bug Bug
Assignee: John Westcott
Components: ansible-tower-plugin
Created: 2019-12-03 14:50
Environment: CloudBees Jenkins : 1.11.22
Managed Master Version: 2.176.4
Priority: Critical Critical
Reporter: Viv Cheolu

Jenkins job is not passing credentials to job template in Tower for Ansible tower version 3.6.1. 

This used to work with Tower version 2.9

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

lily.wang1983000@gmail.com (JIRA)

unread,
Dec 7, 2019, 7:31:02 PM12/7/19
to jenkinsc...@googlegroups.com
Lili Wang commented on Bug JENKINS-60352
 
Re: Ansible Tower Plugin does not pass credentials from job to Ansible tower 3.6.1

Hi ALL,

 

I find the issue,

 

issue is in the source code: ../ansible-tower-plugin/src/main/java/org/jenkinsci/plugins/ansible_tower/util/TowerConnector.java

 

 

Line:517

 

Before Change

// We need to pass individual fields
if(credentials.get("machine").size() > 0) { postBody.put("credential", credentials.get("machine").get(0)); }
if(credentials.get("vault").size() > 0) { postBody.put("vault_credential", credentials.get("vault").get(0)); }

 

After Change:
           // We need to pass individual fields
            if(credentials.get("machine").size() > 0) { postBody.put("credentials", credentials.get("machine")); }
            if(credentials.get("vault").size() > 0) { postBody.put("vault_credential", credentials.get("vault")); }
 

 

Then it should works.

 

Thank you.

 

 

kyle.fattig@gmail.com (JIRA)

unread,
Dec 9, 2019, 9:56:04 AM12/9/19
to jenkinsc...@googlegroups.com

Lili Wang That was the change I tried initially, but 'credentials' takes a list while 'credential' takes a list so tower throws a type error. That's jist of the issue though - Tower 3.6 removed the 'credential' field which is what the plugin sends.

 

Here's the smallest change I could make that seems to work for now. There's already logic in place to account for this, it just needs to be used. Note this will break compatibility with old versions of the API that don't support 'credentials' field. We built this code and are using it for now as a stop-gap since Tower 3.6 supports only 'credentials':
https://github.com/jenkinsci/ansible-tower-plugin/compare/master...kfattig:master

 

John Westcott I believe this code segment needs to be revisited. The comment explains the logic, but I believe it's flawed. Tower only accepts 1 machine credential currently, so 'if' statement is never entered. Since the accepted fields change based on the API version - maybe that should be taken into account here instead?

 

Happy to contribute or test as necessary, just didn't feel confident submitting a full PR without more information & testing.

kyle.fattig@gmail.com (JIRA)

unread,
Dec 9, 2019, 9:57:03 AM12/9/19
to jenkinsc...@googlegroups.com
kyle fattig edited a comment on Bug JENKINS-60352
[~clover1983] That was the change I tried initially, but 'credentials' takes a list while 'credential' takes a list an int so tower throws a type error. That's jist of the issue though - Tower 3.6 removed the 'credential' field which is what the plugin sends.


 

Here's the smallest change I could make that seems to work for now. There's already logic in place to account for this, it just needs to be used. Note this will break compatibility with old versions of the API that don't support 'credentials' field. We built this code and are using it for now as a stop-gap since Tower 3.6 supports only 'credentials':
[https://github.com/jenkinsci/ansible-tower-plugin/compare/master...kfattig:master]

 

[~johnwestcottiv] I believe [this code segment|https://github.com/jenkinsci/ansible-tower-plugin/blob/ea9541646df260ac7ca4c8c626867c96419f2751/src/main/java/org/jenkinsci/plugins/ansible_tower/util/TowerConnector.java#L499-L526] needs to be revisited. The comment explains the logic, but I believe it's flawed. Tower only accepts 1 machine credential currently, so 'if' statement is never entered. Since the accepted fields change based on the API version - maybe that should be taken into account here instead?


 

Happy to contribute or test as necessary, just didn't feel confident submitting a full PR without more information & testing.

kyle.fattig@gmail.com (JIRA)

unread,
Dec 9, 2019, 9:57:04 AM12/9/19
to jenkinsc...@googlegroups.com
kyle fattig edited a comment on Bug JENKINS-60352
[~clover1983] That was the change I tried initially, but 'credentials' takes a list while 'credential' takes an int so tower throws a type error. That's jist of the issue though - Tower 3.6 removed the 'credential' field which is what the plugin sends.


 

Here's the smallest change I could make that seems to work for now. There's already logic in place to account for this, it just needs to be used. Note this will break compatibility with old versions of the API that don't support 'credentials' field. We built this code and are using it for now as a stop-gap since Tower 3.6 supports only 'credentials':
[https://github.com/jenkinsci/ansible-tower-plugin/compare/master...kfattig:master]

 

[~johnwestcottiv] I believe [this code segment|https://github.com/jenkinsci/ansible-tower-plugin/blob/ea9541646df260ac7ca4c8c626867c96419f2751/src/main/java/org/jenkinsci/plugins/ansible_tower/util/TowerConnector.java#L499-L526] needs to be revisited. The comment explains the logic, but I believe it's flawed. Tower only accepts 1 machine credential currently, so the 'if' statement is never entered. Since the accepted fields change based on the API version - maybe that should be taken into account here instead?


 

Happy to contribute or test as necessary, just didn't feel confident submitting a full PR without more information & testing.

john.westcott.iv@redhat.com (JIRA)

unread,
Jan 8, 2020, 9:53:03 AM1/8/20
to jenkinsc...@googlegroups.com
John Westcott resolved as Fixed
 

Please reopen the ticket if the latest release does not resolve this issue.

Change By: John Westcott
Status: Open Resolved
Resolution: Fixed
Released As: 0.14.0

john.westcott.iv@redhat.com (JIRA)

unread,
Jan 8, 2020, 10:00:02 AM1/8/20
to jenkinsc...@googlegroups.com

frederic.leroux@thales-services.fr (JIRA)

unread,
Jan 8, 2020, 12:45:03 PM1/8/20
to jenkinsc...@googlegroups.com
Frederic Leroux commented on Bug JENKINS-60352
 
Re: Ansible Tower Plugin does not pass credentials from job to Ansible tower 3.6.1

Hi,

This patch cause a NullPointerException (with AWX) because towerVersion attribute is apparently not properly filled.

Cheers

java.lang.NullPointerException
	at org.jenkinsci.plugins.ansible_tower.util.TowerConnector.processCredentials(TowerConnector.java:518)
	at org.jenkinsci.plugins.ansible_tower.util.TowerConnector.submitTemplate(TowerConnector.java:564)
	at org.jenkinsci.plugins.ansible_tower.AnsibleTowerRunner.runJobTemplate(AnsibleTowerRunner.java:184)
	at org.jenkinsci.plugins.ansible_tower.AnsibleTowerStep$AnsibleTowerStepExecution.run(AnsibleTowerStep.java:266)
	at org.jenkinsci.plugins.ansible_tower.AnsibleTowerStep$AnsibleTowerStepExecution.run(AnsibleTowerStep.java:202)

john.westcott.iv@redhat.com (JIRA)

unread,
Mar 23, 2020, 10:43:03 AM3/23/20
to jenkinsc...@googlegroups.com

Thanks you for the details, I believe I know what is going on now and am working on a fix. I'll let you know when that has been pushed and is ready for testing. Hopefully that will be later today.

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

john.westcott.iv@redhat.com (JIRA)

unread,
Mar 23, 2020, 12:54:03 PM3/23/20
to jenkinsc...@googlegroups.com

This appears to have been an issue specifically with AWX v8.0.0 which reported its version as 8.0.0.0 (a 4 part notation instead of a three part notation). Jenkins 0.14.1 has been released which should hopefully address this scenario. It may take a couple days to be available for download. Please test and let me know if this now works. 

frederic.leroux@thales-services.fr (JIRA)

unread,
Mar 23, 2020, 1:31:03 PM3/23/20
to jenkinsc...@googlegroups.com

Thanks for the feedback, I'll do the test in a couple of days and keep you posted

Reply all
Reply to author
Forward
0 new messages