Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Coding Releases > Coding Snippets
You last visited: Today at 20:20

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Gitlab to Discord Webhook

Discussion on Gitlab to Discord Webhook within the Coding Snippets forum part of the Coding Releases category.

Reply
 
Old   #1
dotCom
 
Devsome's Avatar
 
elite*gold: 9570
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,812
Received Thanks: 4,663
Gitlab to Discord Webhook

Hallo elitepvpers,

kleines Snippet um die Discord webhooks für gitlab zu benutzen.
Einfach Irgendwo hochladen wo cUrl erlaubt ist und gitlab darauf verlinken.

PHP Code:
<?php
error_reporting
(E_ALL E_STRICT);
ini_set('display_errors''On');

/* Variables editing */
$GitlabToken    "";
$DiscordWebHook "https://ptb.discordapp.com/api/webhooks/";

if( 
$_SERVER['HTTP_X_GITLAB_TOKEN'] ) {
  if( 
$_SERVER['HTTP_X_GITLAB_TOKEN'] = $GitlabToken ) {

    
$json file_get_contents('php://input');
    
$action json_decode($jsontrue);

    
$payloadArr = array(
      
"username"  =>  "Gitlab",
      
"icon_url"  =>  "http://i.epvpimg.com/Rdh7c.jpg",
      
"text"      =>  $action['project']['name'],
      
"attachments" =>  array(
        array(
          
"author_icon" =>  $action['user_avatar'],
          
"author_name" =>  $action['commits'][0]['author']['name'],
          
"color"       =>  "#ffffff",
          
"fields"  => array(
            array(
              
"title" =>  $action['event_name'],
              
"value" =>  "[" substr($action['commits'][0]['id'], 07) . "](" $action['commits'][0]['url'] . ") ",
            ),
          ),
        ),
      ),
    );

    
$payload json_encode($payloadArr);

    
$ch curl_init();
    
$options = array(
      
CURLOPT_URL                   =>    $DiscordWebHook "/slack",
      
CURLOPT_POST                  =>    true,
      
CURLOPT_RETURNTRANSFER        =>    true,
      
CURLOPT_POSTFIELDS            =>    $payload,
      
CURLOPT_HTTPHEADER            =>    array('Content-type: application/json'),
    );
    
curl_setopt_array($ch$options);
    
$result curl_exec($ch);
    
$httpCodeReturned curl_getinfo($chCURLINFO_HTTP_CODE);
    
curl_close($ch);
    
$result_str json_decode($result);

    
/*
     * print_r($result_str);
     * print($payload);
     * */
    
print($httpCodeReturned);

  }
}
Devsome is offline  
Thanks
3 Users
Old 10/21/2016, 18:16   #2
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
Can u post on english too pls ?
mlukac89 is offline  
Old 10/21/2016, 19:00   #3
dotCom
 
Devsome's Avatar
 
elite*gold: 9570
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,812
Received Thanks: 4,663
Quote:
Originally Posted by mlukac89 View Post
Can u post on english too pls ?
Just upload it to any server and change the
PHP Code:
$GitlabToken    "";
$DiscordWebHook "https://ptb.discordapp.com/api/webhooks/"
and enable Webhooks in Gitlab
Devsome is offline  
Thanks
1 User
Old 01/31/2019, 04:08   #4



 
+Yazzn's Avatar
 
elite*gold: 420
Join Date: Jan 2012
Posts: 1,082
Received Thanks: 1,000
In case anyone sees this in <current_year>, GitLab has Discord integration out of the box since version 11.6 https://docs.gitlab.com/ee/user/proj...fications.html
+Yazzn is offline  
Thanks
2 Users
Old 01/29/2024, 15:05   #5


 
teslatx's Avatar
 
elite*gold: 398
The Black Market: 271/0/0
Join Date: May 2020
Posts: 2,447
Received Thanks: 412
Thank you
teslatx is offline  
Reply


Similar Threads Similar Threads
[JS] [Discord Bot] Neptr
11/20/2016 - Coding Releases - 4 Replies
Hey zusammen :) Wollte mir letztens mal die Discord API anschauen und dabei ist dieser Bot entstanden. http://i.epvpimg.com/ov7ug.gif Also warum heißt er Neptr? Mir ist kein besserer Name eingefallen. N.E.P.T.R. ist der Never-Ending-Pie-Throwing-Robot aus Adventure Time :D Was kann er so?
Entwickler für Webhook zu Table
08/15/2016 - Coders Trading - 0 Replies
Ich benötige einen Entwickler der mir die Daten von einer Webhook in eine passende Form bringt. 1. Daten kommen per Webhook von mailparser.io 2. Daten werden per Webhook in Datenbank bzw. das Script geschrieben. 3. Die Daten sollen dann dargestellte werden wie folgt Der Webhook liefert die Daten. Der Timer soll starten bei 05:00 Minuten basierend ab erhalt der E-Mail, sollte also der Webhook 30sec benötigen, so soll dann nur mehr 04:30 angezeigt werden.
Gitlab/Gitorious auf Ubuntu
05/15/2015 - General Coding - 0 Replies
Moin, ich stehe vor einem recht blöden Problem was ich nicht gelöst bekomme. Ich habe einen kleinen VPS und möchte darauf nun Gitorious installieren. Benutzt wird Ubuntu 14.04. Ich befolge ganz simple diese Anleitung von deren Homepage: http://grabilla.com/0550f-f6b74a8d-c802-47d9-9ff8 -fefe143757be.png Sieht ja mal ganz simple aus, ist es ja auch aber Postgres macht mir das Leben schwer, jedesmal beim ausführen der dritten Anweisung schlägt die Installation fehl, weil Postgres...
Discord Art
01/03/2008 - World of Warcraft - 10 Replies
Hi ich suche Discord Art für die aktuelle WoW-Version finde aber leider nichts, wenn einer eine aktuelle Version findet pls verlinken. thx :) mfg NeoAr



All times are GMT +1. The time now is 20:20.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.