jongyoul / gradle-slack-plugin Goto Github PK
View Code? Open in Web Editor NEWSlack plugin for Gradle
License: Apache License 2.0
Slack plugin for Gradle
License: Apache License 2.0
Extract sending logic from task and make it available as a utility method on the extension. In this way people can attach it to a build listener instead of executing a task.
You should allow for the elements in Message
to be lazy-evaluated. This allows evolving state to be included. For instance you can rewrite Message.channel
to be
void setChannel(Object o) {
this.channel = o
}
String getChannel() {
StringUtils.stringize(this.channel)
}
private Object channel
IN this way plugin authors can for instance select the channel dependent on the result
slack {
message {
channel = { -> tasks.getByName('build').state.failure ? '#failed_build; : '#passed_build' }
}
}
You can get the StringUtils.stringize
method from the Grolifant library (https://ysb33rOrg.gitlab.io/grolifant)
Recently this plugin has stopped working. The build doesn't fail, but it doesn't publish to Slack and instead we see this in the console output:
01:30:06.408 [ERROR] [net.madeng.gradle.plugin.slack.SlackTask] Something wrong: 404, ResponseEntityProxy{[Content-Type: text/html,Chunked: true]}
Here's the full debug output with a few key things redacted:
01:30:06.180 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :publishToSlack' started
01:30:06.180 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Putting task artifact state for task ':publishToSlack' into context took 0.0 secs.
01:30:06.180 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':publishToSlack' is up-to-date
01:30:06.181 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Task ':publishToSlack' is not up-to-date because:
Task has not declared any outputs despite executing actions.
01:30:06.181 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':publishToSlack'.
01:30:06.181 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute publishToSlack for :publishToSlack' started
01:30:06.182 [DEBUG] [net.madeng.gradle.plugin.slack.SlackTask] message: {"attachments":[{"color":"good","fields":[{"title":"xxxxxxxxx","value":"`xxxxxxxxx`","short":true},{"title":"GroupId","value":"`xxxxx`","short":true},{"title":"ArtifactId","value":"`xxxxxxxx`","short":true},{"title":"Version","value":"`1.0.8`","short":true}],"actions":[],"ts":1542187806}],"channel":"#new-artifacts","text":"*Published new artifact to Maven repo.*"}
01:30:06.184 [DEBUG] [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: default
01:30:06.184 [DEBUG] [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context
01:30:06.185 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection request: [route: {s}->https://hooks.slack.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
01:30:06.185 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection leased: [id: 3][route: {s}->https://hooks.slack.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
01:30:06.186 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {s}->https://hooks.slack.com:443
01:30:06.186 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to hooks.slack.com/13.33.226.131:443
01:30:06.186 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Connecting socket to hooks.slack.com/13.33.226.131:443 with timeout 0
01:30:06.221 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Enabled protocols: [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1]
01:30:06.221 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Enabled cipher suites:[TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
01:30:06.221 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Starting handshake
01:30:06.298 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Secure session established
01:30:06.298 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] negotiated protocol: TLSv1.2
01:30:06.298 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
01:30:06.300 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] peer principal: CN=slack.com, O="Slack Technologies, Inc.", L=San Francisco, ST=CA, C=US
01:30:06.300 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] peer alternative names: [slack.com, *.slack.com]
01:30:06.302 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] issuer principal: CN=DigiCert SHA2 Secure Server CA, O=DigiCert Inc, C=US
01:30:06.304 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connection established 10.1.64.23:61602<->13.33.226.131:443
01:30:06.304 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request POST /services/Txxxxxxx/Bxxxxxxxx/xxxxxxxxxxxxxxxxxx HTTP/1.1
01:30:06.304 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Target auth state: UNCHALLENGED
01:30:06.304 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Proxy auth state: UNCHALLENGED
01:30:06.408 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection can be kept alive indefinitely
01:30:06.408 [ERROR] [net.madeng.gradle.plugin.slack.SlackTask] Something wrong: 404, ResponseEntityProxy{[Content-Type: text/html,Chunked: true]}
01:30:06.408 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute publishToSlack for :publishToSlack'
I have a setup like this:
test {
// Use TestNG for unit tests
useTestNG()
}
slack {
webhookUrl '<webhook>'
message {
text = "Test *hello world*"
channel = '#ins-alerts'
attachment {
authorName = 'hello'
color = 'good'
title = "Branch: test"
titleLink = "https://github.com/link/i/want/to/redirect"
field {
title = 'Built'
value = 'Success'
shortValue = true
}
field {
title = 'Deployed'
value = 'Success'
shortValue = true
}
action {
name = 'game'
text = 'Chess'
type = "button"
value = "chess"
}
action {
name = 'game'
text = 'Thermonuclear War'
style = 'danger'
type = 'button'
value = 'war'
confirm {
title = 'Are you sure?'
text = 'Wouldn\'t you prefer a good game of chess?'
okText = 'Yes'
dismissText = 'No'
}
}
}
}
}
I would like to feed test results into this slack plugin, how I do I do that?
When creating an block element of type actions, it is not currently possible to create a button that is associated to a url
.
This is described here: https://api.slack.com/reference/block-kit/block-elements
Would love an example of how to use this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.