简体   繁体   中英

How to integrate maven with slack?

I would like to send specific slack messages to a channel/user on a build phase. I know I can create a maven plugin, perhaps there is one already?

Did it myself: https://github.com/moacyrricardo/maven-slack

With this plugin all you have to do as add a webhook to slack and use the url to post messages.

To use it, add the 's3 wagon extension' to your pom.xml:

<build>  
     <extensions>  
       <extension>  
         <groupId>org.springframework.build.aws</groupId>  
         <artifactId>org.springframework.build.aws.maven</artifactId>  
         <version>3.0.0.RELEASE</version>  
       </extension>  
     </extensions>  
  </build>

Then the plugin repo:

<pluginRepository>
  <id>s3-moarepo</id>
  <url>s3://moarepo/release</url>
  <releases>  
     <enabled>true</enabled>  
   </releases>  
   <snapshots>  
     <enabled>false</enabled>  
   </snapshots> 
</pluginRepository>
<pluginRepository>
  <id>s3-moarepo-snapshot</id>
  <url>s3://moarepo/snapshot</url>
  <releases>  
     <enabled>false</enabled>  
   </releases>  
   <snapshots>  
     <enabled>true</enabled>  
   </snapshots> 
</pluginRepository>

And finally you can use it

<plugin>
    <groupId>br.com.kibutx</groupId>
    <artifactId>slack-maven-plugin</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <executions>
        <execution>
            <id>MSG inicio deploy</id>
            <phase>validate</phase>
            <goals>
                <goal>slackmessage</goal>
            </goals>
            <configuration>
                <apiHash>hash1/hash2/hash3</apiHash>
                <channel>@devmate</channel>
                <message>Short message</message>
                <fields>
                    <field>
                        <value>Field 1 value</value>
                    </field>
                </fields>
            </configuration>
        </execution>
    </executions>
</plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM