dpl icon indicating copy to clipboard operation
dpl copied to clipboard

Fix for Issue #1190 - Including Org and Space in bluemixcloudfoundry provider

Open jpwsutton opened this issue 4 years ago • 3 comments

Resolves #1190

This fix includes two main changes:

  1. Adds -o and -s arguments into the cf login command so that the organization and space is automatically targeted rather than blocking the build with the interactive org selection menu.
  2. Adds double quotes to all instances where the organization and space variables are used to mitigate failing builds when said variables contain spaces.

I don't have an example build on public travis as I was facing this issue on travis enterprise, I've included the before and after logs below to show the fix though:

Before (Failing)

Authenticate deployment
$ ./cf api api.eu-gb.bluemix.net
Setting api endpoint to api.eu-gb.bluemix.net...
OK
api endpoint:   https://api.eu-gb.bluemix.net
api version:    2.147.0
Not logged in. Use 'cf login' or 'cf login --sso' to log in.
$ ./cf login -u apikey -p ********************
API endpoint: https://api.eu-gb.bluemix.net
Authenticating...
OK
Select an org:
1. One of My Orgs
2. Another Organization
3. Personal Projects

(at which point the build freezes waiting for user input)

After (fixed)

Authenticate deployment
$ ./cf api api.eu-gb.bluemix.net
Setting api endpoint to api.eu-gb.bluemix.net...
OK
api endpoint:   https://api.eu-gb.bluemix.net
api version:    2.147.0
Not logged in. Use 'cf login' or 'cf login --sso' to log in.
$ ./cf login -u apikey -p ******************** -o "Another Organization" -s "myspace"
API endpoint: https://api.eu-gb.bluemix.net
Authenticating...
OK
Targeted org Another Organization
Targeted space myspace
API endpoint:   https://api.eu-gb.bluemix.net
                (API
                version:
                2.147.0)
User:           [email protected]
Org:            Another
                Organization
Space:          myspace
$ ./cf target -o "Another Organization" -s "myspace"
api endpoint:   https://api.eu-gb.bluemix.net
api version:    2.147.0
user:           [email protected]
org:            Another
                Organization
space:          myspace

jpwsutton avatar May 01 '20 11:05 jpwsutton

Does this change apply to CloudFoundry as well?

BanzaiMan avatar May 05 '20 20:05 BanzaiMan

I think it would, fortunately the CloudFoundry provider already has the Org and Space defined in the login command (https://github.com/travis-ci/dpl/blob/master/lib/dpl/providers/cloudfoundry.rb#L30)

It doesn't have them in quotes, so I guess it could be an improvement to add quotes to those arguments as well, but I'd have no way to test as I don't have an account with any other CF instance.

jpwsutton avatar May 06 '20 09:05 jpwsutton

OK. Can you point to a test deployment using this PR? After that, we can merge.

BanzaiMan avatar May 06 '20 18:05 BanzaiMan