Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jpwsutton
Copy link

@jpwsutton jpwsutton commented May 1, 2020

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

Adding the -o and -s arguments to the login command to prevent the cf command from blocking the build indefinitely during login.
Organization and Space names can have spaces in them which will break the login and target commands.
Rather than expecting the user to discover this and fix in their .travis.yml files, it's easy enough to just add the `"` in here.
Modifying the tests to check the commands correctly.
@BanzaiMan
Copy link
Contributor

Does this change apply to CloudFoundry as well?

@jpwsutton
Copy link
Author

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.

@BanzaiMan
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bluemixcloudfoundry provider freezes build on cf login step
2 participants