2

I’m using Codeship to automate a multi-tenancy application. My app need subdomain setting to run acceptance tests using Selenium Web Driver. So, I need to config virtual domain for my app. For example, I need the following virtual domain: 127.0.0.1 test.my-app.test 127.0.0.1 my-app.test If I do not use subdomain to request to my app, It not work as requirement. I tried the following commands in Setup Commands section before Test Pipelines. sudo echo '127.0.0.1 test.my-app.test' >> /etc/hosts sudo echo '127.0.0.1 my-app.test' >> /etc/hosts But, It doesn’t work, because I has no permission. The error message was: bash: /etc/hosts: Permission denied

Would you mind tell me how to make it work ?

Thank you in advanced !

Update:

I received reply from Codeship team:

this is not possible in our classic infrastructure due to technical limitations. You could move to our Docker Platform, which allows more customization of your build environment.

We need to use Docker to solve this issue

Chung
  • 947
  • 1
  • 12
  • 22

2 Answers2

0

Your redirected command will not be executed in the root privilege, that's why you got the Permission denied error. Your command means "do the echo in the privilege root, then redirected to /etc/hosts file".

Try this:

sudo sh -c 'echo "Your text" >> /path/to/file'
library
  • 1
  • 1
0

We don't allow access via sudo on the build VMs because of security considerations.

However, you can use a service like http://xip.io/ or lvh.me to access your application via DNS names.

$ nslookup codeship.lvh.me
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
Name:   codeship.lvh.me
Address: 127.0.0.1

lvh.me will resolve any requests to a subdomain to 127.0.0.1, xip.io offers more functionality, that is explained on its homepage in more detail.

mlocher
  • 766
  • 5
  • 11