Skip to content

Commit

Permalink
fix(gradle): only throw for timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 14, 2020
1 parent 575ba10 commit 16d92ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 66 deletions.
24 changes: 0 additions & 24 deletions lib/manager/gradle/__snapshots__/index.spec.ts.snap
Expand Up @@ -505,30 +505,6 @@ Array [
]
`;

exports[`manager/gradle extractPackageFile should throw registry failure if gradle execution fails 1`] = `[Error: registry-failure]`;

exports[`manager/gradle extractPackageFile should throw registry failure if gradle execution fails 2`] = `
Array [
Object {
"cmd": "./gradlew --init-script renovate-plugin.gradle renovate",
"options": Object {
"cwd": "localDir",
"encoding": "utf-8",
"env": Object {
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
"LANG": "en_US.UTF-8",
"LC_ALL": "en_US",
"NO_PROXY": "localhost",
"PATH": "/tmp/path",
},
"timeout": 20000,
},
},
]
`;

exports[`manager/gradle extractPackageFile should use docker even if gradlew is available 1`] = `
Array [
Object {
Expand Down
9 changes: 0 additions & 9 deletions lib/manager/gradle/index.spec.ts
Expand Up @@ -91,15 +91,6 @@ describe('manager/gradle', () => {
expect(execSnapshots).toMatchSnapshot();
});

it('should throw registry failure if gradle execution fails', async () => {
const execSnapshots = mockExecAll(exec, new Error());

await expect(
manager.extractAllPackageFiles(config, ['build.gradle'])
).rejects.toMatchSnapshot();
expect(execSnapshots).toMatchSnapshot();
});

it('should return empty if there is no dependency report', async () => {
const execSnapshots = mockExecAll(exec, gradleOutput);

Expand Down
39 changes: 6 additions & 33 deletions lib/manager/gradle/index.ts
Expand Up @@ -78,41 +78,14 @@ async function executeGradle(
try {
logger.debug({ cmd }, 'Start gradle command');
({ stdout, stderr } = await exec(cmd, execOptions));
} catch (err) {
// istanbul ignore if
} catch (err) /* istanbul ignore next */ {
if (err.code === TIMEOUT_CODE) {
logger.warn({ err }, ' Process killed. Possibly gradle timed out.');
const error = new DatasourceError(err);
error.datasource = 'gradle';
throw error;
}
// istanbul ignore if
if (err.message.includes('Could not resolve all files for configuration')) {
logger.debug({ err }, 'Gradle error');
logger.warn('Gradle resolution error');
return;
}
// istanbul ignore if
if (
err.message.includes('Could not read script') ||
err.message.includes('No such file or directory')
) {
logger.warn(
{ message: err.message },
'Gradle extraction failed due to missing file. Gradle will be skipped.'
);
return;
}
// istanbul ignore if
if (err.message.includes("Could not get unknown property 'classesDir'")) {
logger.warn(
{ message: err.message },
'Gradle extraction failed due to incompatibility. Gradle will be skipped.'
);
return;
}
logger.warn({ err, cmd }, 'Gradle run failed');
logger.info('Aborting Renovate due to Gradle lookup errors');
const error = new DatasourceError(err);
error.datasource = 'gradle';
throw error;
logger.info({ errMessage: err.message }, 'Gradle extraction failed');
return;
}
logger.debug(stdout + stderr);
logger.info('Gradle report complete');
Expand Down

0 comments on commit 16d92ce

Please sign in to comment.