From 7edaef2cd643ff706874c74c848ef160bee3c08e Mon Sep 17 00:00:00 2001 From: Rechi Date: Sat, 26 Jan 2019 22:25:01 +0100 Subject: [PATCH] add option to comment build log for successful builds (#145) --- README.md | 1 + ...ct-failure-data.pipe.js => collect-build-data.pipe.js} | 0 pipes/finish.pipe.js | 1 + pipes/format-message.pipe.js | 8 ++++---- resources/default-config.yml | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) rename pipes/{collect-failure-data.pipe.js => collect-build-data.pipe.js} (100%) diff --git a/README.md b/README.md index 9c89694..a525d2c 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Key | Description | Values regex | Tells TravisBuddy to take only parts of the log. The regex is executed on each test script separately, and TravisBuddy will only show the first result catched using parentheses | Any valid regular expression regexOptions | Use along with `regex` to apply regular expression options | Any valid regular expression option, i.e. `g` insertMode | Tells TravisBuddy to comment once and keep editing that one comment instead of appending new comment for every build | (default) `append` or `update` +successBuildLog | Tells TravisBuddy to add the build log for successfull builds. | (default) `false` or `true` #### Custom Template diff --git a/pipes/collect-failure-data.pipe.js b/pipes/collect-build-data.pipe.js similarity index 100% rename from pipes/collect-failure-data.pipe.js rename to pipes/collect-build-data.pipe.js diff --git a/pipes/finish.pipe.js b/pipes/finish.pipe.js index e23c870..71984ad 100644 --- a/pipes/finish.pipe.js +++ b/pipes/finish.pipe.js @@ -26,6 +26,7 @@ const finish = context => { link: context.link, language: context.language, insertMode: context.config.insertMode, + successBuildLog: context.config.successBuildLog, commentId: context.commentId, buildNumber: context.buildNumber, payload: JSON.stringify(context.payload, null, 4), diff --git a/pipes/format-message.pipe.js b/pipes/format-message.pipe.js index 041524e..eab3c0b 100644 --- a/pipes/format-message.pipe.js +++ b/pipes/format-message.pipe.js @@ -1,6 +1,6 @@ const paipu = require('paipu'); const mustache = require('mustache'); -const collectFailureData = require('./collect-failure-data.pipe'); +const collectBuildData = require('./collect-build-data.pipe'); const fetchTemplate = require('./fetch-template.pipe'); const logger = require('../utils/logger'); @@ -47,9 +47,9 @@ const formatMessage = async context => { module.exports = paipu .pipeIf( - context => context.state === 'failed', - 'collect failure data', - collectFailureData, + context => context.state === 'failed' || (context.query.successBuildLog || context.config.successBuildLog) === 'true', + 'collect build data', + collectBuildData, ) .pipe('fetch template', fetchTemplate) .pipe('format message', formatMessage); diff --git a/resources/default-config.yml b/resources/default-config.yml index de02acd..d5738da 100644 --- a/resources/default-config.yml +++ b/resources/default-config.yml @@ -3,3 +3,4 @@ travisBuddy: success: default failure: default insertMode: append + successBuildLog: false