A couple of days ago our team accidentally released a version of the application, which we are working on, with missing string resources for some translations. Of course, we want to be sure that it won’t happen again and the only viable option is to automate it! But, at first, I need to give you some overview of our current release process to be sure that we are on the same page.

We are running lint checks against every pull request and gathering stats from it in order to feed them to the Jenkins Android Lint Plugin. Based on these stats we have a certain threshold for a maximum amount of violations which are allowed for a build to be marked as successful. In order to be able to gather these statistics, we want to be sure that build will be finished without errors even if it contains some lint violations. For that purpose, we had to make this adjustment to our build.gradle :

Which is not ideal, of course, but we haven’t seen other option back there.

We have a localisation management tool integrated into our CI system so we don’t have to care about translations during the development process. For that reason our lint.xml contains:

So we won’t get missing translation violations from the lint checks during the development process.

Building and uploading to the Play Store of release client are handled by the CI system after merging changes into the master branch.

It turned out that we need a solution which meets the following requirements:

Building release client should fail if translations are missing;

Regular CI builds shouldn’t fail due to lint violations, so we can continue to gather lint stats from it;

Local builds should fail due to lint violations so we can fail fast and avoid pushing code with serious lint issues into the CI system.

And here the ability to pass command line arguments comes handy. Turns out that we need to set the abortOnError value to false only for the CI jobs related to pull requests. For other cases like local and release builds setting the abortOnError value to true is perfectly fine. So we can modify build.gradle :

And execute the following command for the CI jobs triggered by pull requests:

So now we can control if our build is going to fail due to lint violations or not. But we are still missing something — release build won’t fail because of missing translations since we downgraded the severity of MissingTranslation check to just a warning. And here is the last trick — before building the release version we can modify lint.xml and remove mentioning of the MissingTranslation check using grep:

Now everything is in place and if there are any missing translations — application just won’t compile and won’t be uploaded to the Play Store, while we still can enjoy our lint statistics graph and don’t be blocked by missing translation during the development process.