Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop services on Travis CI running by default?

The machine instances running for Travis CI start some services by default which are not useful to my project. Therefore I want to stop these services. My first idea was to use the following block in my .travis.yml to do so:

before_script:
  # Disable services enabled by default
  - sudo service mysql stop
  - sudo service postgresql stop

However, this was successful for one and failed for another machine:

$ sudo service mysql stop
mysql stop/waiting

$ sudo service postgresql stop
 * Stopping PostgreSQL 9.1 database server
   ...done.
 * Stopping PostgreSQL 9.2 database server
   ...done.
 * Stopping PostgreSQL 9.3 database server
   ...done.

...

$ sudo service mysql stop    
stop: Unknown instance:

The command "sudo service mysql stop" failed and exited with 1 during .

Another option is /etc/init.d/mysql stop but this could fail on a machine which started the process via the service command. Is there a try-catch I can use in the .travis.yml script?

like image 477
JJD Avatar asked Dec 09 '14 15:12

JJD


People also ask

How do you debug a Travis build?

The “Debug build” or “Debug job” button is available on the upper right corner of the build and job pages for private repositories. For open source repositories, this button is not available and you will need to use an API call instead.

Which of the following are two main parts of Travis CI job?

The first job is to build the image and the second job is going to be to run the NPM test target.

What is Travis CI used for?

As a continuous integration platform, Travis CI supports your development process by automatically building and testing code changes, providing immediate feedback on the success of the change. Travis CI can also automate other parts of your development process by managing deployments and notifications.

Which of the following analysis tool is used for code coverage in Travis CI?

Coveralls is a hosted analysis tool, providing statistics about your code coverage. Configuring your Travis CI build to send results to Coveralls always follows the same pattern: Add your repository to Coveralls.


1 Answers

It turns out that using the mentioned /etc/init.d/ ... works more reliable. There are some warnings that one should use sudo service ... but I was not successful with those. So here is what I am running now:

language: android

jdk:
  - oraclejdk7
  - openjdk7

android:
  components:

    # All the build system components should be at the latest version
    - tools
    - platform-tools
    - build-tools-21.1.1
    - android-19

    # The libraries we can't get from Maven Central or similar
    - extra-android-support


notifications:
  email: true

before_script:

  # Disable services enabled by default
  # http://docs.travis-ci.com/user/database-setup/#MySQL
  - sudo /etc/init.d/mysql stop
  - sudo /etc/init.d/postgresql stop
  # The following did not work reliable
  # - sudo service mysql stop
  # - sudo service postgresql stop

  # Ensure Gradle wrapper is executable
  - chmod +x gradlew

  # Ensure signing configuration is present
  - mv app/gradle.properties.example app/gradle.properties

script:
  - ./gradlew clean assembleDebug
like image 120
JJD Avatar answered Oct 13 '22 20:10

JJD