Code Monkey home page Code Monkey logo

pipeline-giphy-api-plugin's Introduction

Pipeline Giphy Api plugin

Jenkins Plugin Jenkins Plugin Installs

Table of Contents

Introduction

This plugin expose giphy API within your Jenkins pipeline, both straight forward APIs and some customs.
For more information look here: Giphy for Developers

Configuration

Set your api key in credentials section on Jenkins.

  1. Choose Credentials
    credentials-step-1
  2. Choose System
    credentials-step-2
  3. Choose Global credentials
    credentials-step-3
  4. Choose Add Credentials
    credentials-step-4
  5. Fill the form as follow
    credentials-step-5
    1. Kind: Secret text
    2. Scope: Global
    3. Secret:
    4. ID: The id to use in the pipelines
    5. Description: Write whatever you want

Steps

Giphy Search API Steps

giphySearch - return list of urls matched to the keyword
giphySearchRandomByKeyword - return the url of random gif by the keyword. my custom implementation of Giphy Random API

Search Variables

  • credentialsId required - The credential you saved to jenkins. See here.
  • keyword required - The Keyword to search.
  • rating default - g - MPAA rating filters of the images - Y, G, PG, PG-13 and R.
  • imageSize default - downsized_medium - Image size from giphy. See more details here.

Search Example

Search Declarative pipeline

pipeline {
  agent none
  stages {
    stage("foo") {
      steps {
          echo giphySearch(credentialsId: 'giphy', keyword: 'success', rating: 'g').toString()
      }
    }
  }
}

Output is:

Started by user unknown or anonymous
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] stage
[Pipeline] { (foo)
[Pipeline] giphySearch
[Pipeline] echo
[https://media0.giphy.com/media/l3q2BXqLMnzhVF720/giphy.gif, https://media0.giphy.com/media/3o7TKtsBMu4xzIV808/giphy.gif, https://media3.giphy.com/media/LWVn0cCgpRt8Q/giphy.gif, https://media0.giphy.com/media/V80Bk9rW9ZpVC/giphy.gif, https://media1.giphy.com/media/xNBcChLQt7s9a/giphy.gif, https://media1.giphy.com/media/l3q2Z6S6n38zjPswo/giphy.gif, https://media1.giphy.com/media/GS1VR900wmhJ6/giphy.gif, https://media1.giphy.com/media/yGlu7x5jfWGZi/giphy.gif, https://media1.giphy.com/media/2vA33ikUb0Qz6/giphy.gif, https://media1.giphy.com/media/3ov9jSmllAIKuthAe4/giphy.gif, https://media2.giphy.com/media/3ohhwo4PzDFaz2sADu/giphy.gif, https://media2.giphy.com/media/itVfItoFSikqQ/giphy.gif, https://media0.giphy.com/media/T0WzQ475t9Cw/giphy.gif, https://media3.giphy.com/media/nXxOjZrbnbRxS/giphy.gif, https://media3.giphy.com/media/111ebonMs90YLu/giphy.gif, https://media0.giphy.com/media/uudzUtVcsLAoo/giphy.gif, https://media0.giphy.com/media/4xpB3eE00FfBm/giphy-downsized-medium.gif, https://media1.giphy.com/media/OHZ1gSUThmEso/giphy.gif, https://media1.giphy.com/media/zaqclXyLz3Uoo/giphy.gif, https://media2.giphy.com/media/XreQmk7ETCak0/giphy.gif, https://media0.giphy.com/media/KEVNWkmWm6dm8/giphy.gif, https://media2.giphy.com/media/vtVpHbnPi9TLa/giphy.gif, https://media2.giphy.com/media/oGO1MPNUVbbk4/giphy.gif, https://media0.giphy.com/media/26gsobowozGM9umBi/giphy.gif, https://media3.giphy.com/media/aWRWTF27ilPzy/giphy.gif]
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS

Search Scripted pipeline

node {
    def gif = giphySearchRandomByKeyword(credentialsId: 'giphy', keyword: "keyword", rating: 'g', imageSize: 
    'downsized_medium')
    echo gif
}

Output is:

Started by user unknown or anonymous
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in D:\GitHub\giphy-plugin\work\jobs\test\workspace
[Pipeline] {
[Pipeline] giphySearchRandomByKeyword
[Pipeline] echo
https://media3.giphy.com/media/1tykcAaWUvIY/giphy-downsized-medium.gif
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

Giphy Translate API Steps

giphyTranslate - return url matched to the keyword

Translate Variables

  • credentialsId required - The credential you saved to jenkins. See here.
  • keyword required - The Keyword to search.
  • imageSize default - downsized_medium - Image size from giphy. See more details here.

Translate Example

Translate Declarative pipeline

pipeline {
  agent none
  stages {
    stage("foo") {
      steps {
          echo giphyTranslate(credentialsId: 'giphy', keyword: 'success').toString()
      }
    }
  }
}

Output is:

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] stage
[Pipeline] { (foo)
[Pipeline] giphyTranslate
[Pipeline] echo
https://media2.giphy.com/media/2cZlphZGMk4RW/giphy.gif
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS

Translate Scripted pipeline

node {
    def gif = giphyTranslate(credentialsId: 'giphy', keyword: "keyword", imageSize: 
    'downsized_medium')
    echo gif
}

Output is:

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/test
[Pipeline] {
[Pipeline] giphyTranslate
[Pipeline] echo
https://media1.giphy.com/media/2t9ASqRNjQTNNXv5ob/giphy-downsized-medium.gif
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

Giphy Trending API Steps

TODO

Giphy Random API Steps

giphyRandom - return random url matched to the keyword

Random Variables

  • credentialsId required - The credential you saved to jenkins. See here.
  • tag required - The tag to search.
  • rating default - g - MPAA rating filters of the images - Y, G, PG, PG-13 and R.
  • imageSize default - downsized_medium - Image size from giphy. See more details here.

Random Example

Random Declarative pipeline

pipeline {
  agent none
  stages {
    stage("foo") {
      steps {
          echo giphyRandom(credentialsId: 'giphy', tag: 'success').toString()
      }
    }
  }
}

Output is:

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] stage
[Pipeline] { (foo)
[Pipeline] giphyRandom
[Pipeline] echo
https://media2.giphy.com/media/cN1RJVaYCht96/giphy.gif
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS

Random Scripted pipeline

node {
    def gif = giphyRandom(credentialsId: 'giphy', tag: "tag", rating: 'pg-13', imageSize: 
    'downsized_medium')
    echo gif
}

Output is:

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/test
[Pipeline] {
[Pipeline] giphyRandom
[Pipeline] echo
https://media0.giphy.com/media/6pipAdjEVrVBK/giphy.gif
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

pipeline-giphy-api-plugin's People

Contributors

aviadlevy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

gounthar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.