All Projects → jenkinsci → pipeline-as-yaml-plugin

jenkinsci / pipeline-as-yaml-plugin

Licence: MIT license
Jenkins Pipeline As Yaml Plugin

Programming Languages

java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pipeline-as-yaml-plugin

jenkins-pipeline-shared-library-template
Project template for developing shared Jenkins pipeline libraries.
Stars: ✭ 46 (-58.56%)
Mutual labels:  jenkins, jenkins-pipeline, pipeline-as-code
artifact-promotion-plugin
A simple Jenkins plugin to promote artifacts.
Stars: ✭ 29 (-73.87%)
Mutual labels:  jenkins, pipeline, jenkins-plugin
learn-ansible-and-jenkins-in-30-days
Ansible + Jenkins in 30 days tutorial.
Stars: ✭ 35 (-68.47%)
Mutual labels:  jenkins, jenkins-plugin, jenkins-pipeline
bitbucket-push-and-pull-request-plugin
Plugin for Jenkins v2.138.2 or later, that triggers job builds on Bitbucket's push and pull request events.
Stars: ✭ 47 (-57.66%)
Mutual labels:  jenkins, pipeline, jenkins-plugin
pipeline-maven-plugin
Pipeline Maven Plugin
Stars: ✭ 50 (-54.95%)
Mutual labels:  jenkins, jenkins-plugin, jenkins-pipeline
Jira Steps Plugin
Jenkins pipeline steps for integration with JIRA.
Stars: ✭ 88 (-20.72%)
Mutual labels:  jenkins, pipeline, jenkins-plugin
Jenkins Os
Groovy pipeline jobs that build and test Container Linux with Jenkins
Stars: ✭ 43 (-61.26%)
Mutual labels:  jenkins, pipeline, jenkins-plugin
pipeline-github-plugin
Pipeline: GitHub
Stars: ✭ 151 (+36.04%)
Mutual labels:  pipeline, jenkins-plugin, jenkins-pipeline
Ssh Steps Plugin
Jenkins pipeline steps which provides SSH facilities such as command execution or file transfer for continuous delivery.
Stars: ✭ 183 (+64.86%)
Mutual labels:  jenkins, pipeline
Hashicorp Vault Plugin
Jenkins plugin to populate environment variables from secrets stored in HashiCorp's Vault.
Stars: ✭ 191 (+72.07%)
Mutual labels:  jenkins, jenkins-plugin
configuration-as-code-secret-ssm-plugin
AWS SSM Plugin for Jenkins Configuration as Code
Stars: ✭ 22 (-80.18%)
Mutual labels:  jenkins, jenkins-plugin
Performance Plugin
Performance Test Running and Reporting for Jenkins CI
Stars: ✭ 176 (+58.56%)
Mutual labels:  jenkins, jenkins-plugin
Stashnotifier Plugin
A Jenkins Plugin to notify Atlassian Stash|Bitbucket of build results
Stars: ✭ 157 (+41.44%)
Mutual labels:  jenkins, jenkins-plugin
Jenkinsdocs
Jenkins实践文档 最新站点地址: http://www.idevops.site
Stars: ✭ 200 (+80.18%)
Mutual labels:  jenkins, pipeline
Sonar Scanner Jenkins
SonarQube Scanner for Jenkins
Stars: ✭ 155 (+39.64%)
Mutual labels:  jenkins, jenkins-plugin
Dropseqpipe
A SingleCell RNASeq pre-processing snakemake workflow
Stars: ✭ 119 (+7.21%)
Mutual labels:  yaml, pipeline
Jenkins Job Wrecker
convert Jenkins job XML to JJB YAML
Stars: ✭ 152 (+36.94%)
Mutual labels:  yaml, jenkins
Demo Jenkins Config As Code
Demo of Jenkins Configuration-As-Code with Docker and Groovy Hook Scripts
Stars: ✭ 143 (+28.83%)
Mutual labels:  jenkins, pipeline
pipeline
Spline is a tool that is capable of running locally as well as part of well known pipelines like Jenkins (Jenkinsfile), Travis CI (.travis.yml) or similar ones.
Stars: ✭ 29 (-73.87%)
Mutual labels:  yaml, pipeline
My Bloody Jenkins
Self Configured Jenkins Docker image based on Jenkins-LTS
Stars: ✭ 205 (+84.68%)
Mutual labels:  yaml, jenkins

Pipeline As Yaml Plugin for Jenkins (Incubating)

This plugin enables defining Jenkins Pipelines in YAML Format for Pipeline and MultiBranch Pipeline Jobs.

Incubation Stage: Currently this plugin is in the incubation stage. It will evolve further to become more aligned with the Pipeline ecosystem, and some breaking changes are plausible. You are welcome to try out this plugin and to provide your feedback. Contributions are welcome!

Description

Jenkins enables defining pipelines with specific DSL. With this plugin Jenkins pipelines can be defined in Yaml format.

Defined Yaml format is converted to Jenkins Pipeline Declarative syntax in runtime.

Any existing steps in Snippet Generator or Declarative Directive Generator can bu used in step or script block.

Jenkins Declarative Pipeline Syntax rules must be followed.

Please see below for usage examples.

Usage

Pipeline

For using Pipeline As Yaml in your Pipeline Job, select one of the possible options.

Editor

Define Pipeline As Yaml with embedded editor.

pipelineAsScript

SCM

Retrieve Pipeline As Yaml from SCM Definition

pipelineAsScm

MultiBranch Pipeline

For using Pipeline as Yaml in your MultiBranch Pipeline, select by Jenkinsfile As Yaml' in Build Configuration`.

Build Configuration

Pipeline As Yaml Syntax

Pipeline definition must stat with pipeline key.

For detailed usage examples please check here.

pipeline:
  agent: any
    ...
    ...

Agent

Example agent definition is shown below. Agent definitions can be used under stage definitions.

For further supported definitions syntax please check.

pipeline:
  agent:
    node:
      label: 'label'

Environment

Example definition is shown below. Environment definitions can be used under stage definitions.

For further supported definitions syntax please check.

pipeline:
  environment:
    KEY1: "VAL1"

Options

Example definition is shown below. Options definitions can be used under stage definitions.

For further supported definitions syntax please check.

pipeline:
  options:
    - "timeout(time: 1, unit: 'HOURS')"
    # Or any other 'options' directive which is generated by Declarative Directive Generator

Post

Example definition is shown below. Post definitions can be used under stage definitions.

For further supported definitions syntax please check.

pipeline:
  post:
    always:
      - echo Test
    changed:
      - echo Test
    # Or any other 'post' directive which is generated by Declarative Directive Generator 

Tools

Example definition is shown below. Tools definitions can be used under stage definitions.

For further supported definitions syntax please check.

pipeline: 
  tools:
    maven: "maven"
    # Or any other 'tools' directive which is generated by Declarative Directive Generator" 

When

Example definition is shown below. When definitions can be used under stage definitions.

For further supported definitions syntax please check.

pipeline:
  stages:
    - stage: "WhenTest"
      when:
        - "branch 'production'"
      # Or any other 'when' directive which is generated by Declarative Directive Generator" 

Parameters

Example definition is shown below.

For further supported definitions syntax please check.

pipeline:
  parameters:
    - "string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')"
    # Or any other 'parameters' directive which is generated by Declarative Directive Generator" 

Triggers

Example definition is shown below.

For further supported definitions syntax please check.

pipeline:
  triggers:
    - cron('H */4 * * 1-5')
    # Or any other 'triggers' directive which is generated by Declarative Directive Generator" 

Library

Example definition is below.

Before using Library feature please read here

For further supported definitions syntax please check.

pipeline:
  library: "library@master"
  agent:
    any:
  stages:
    - stage: "Stage Library"
      steps:
        script:
          - "myCustomStepInLibrary"

Stages

Example definition is shown below.

For further supported definitions syntax please check.

pipeline:
  agent:
    none:
  stages:
    - stage: "Stage1"
      steps:
        - echo "1"
    - stage: "Stage2"
      steps:
        - echo "2"
pipeline:
  agent:
    none:
  stages:
    - stage: "Stage1"
      stages:
        - stage: "Inner Stage1"
          steps:
            - echo "1" 
pipeline:
  stages:
    - stage: "Stage1"
      steps:
        - echo "1"
    - stage: "Parallel"
      parallel:
        - stage: "Parallel1"
          steps:
            - echo "P1"
        - stage: "Parallel2"
          steps:
            - echo "P1"

Steps

Example definition is shown below.

Any other 'step' which is generated by Snippet Generator can be used in steps definitions.

For further supported definitions syntax please check.

pipeline:
  stages:
    - stage: "Stage"
      steps:
        - echo env.WORKSPACE # Or any other 'step' which is generated by Snippet Generator" 

Any other 'step' which is generated by Snippet Generator or Groovy Script can be used in steps definitions.

pipeline:
  stages:
    - stage: "Stage1"
      steps:
        script:
          - echo "1" # Or any other 'step' which is generated by Snippet Generator, Groovy Script" 

For implementing complex scripts or steps

pipeline:
  stages:
    - stage: "Stage1"
      steps:
        script: |
          echo "1"
          echo "2"
          echo "3"

Special Steps With Code Blocks

Some steps has their own code blocks. For example: 'withAnt, withEnv, withCredentials, dir' or any other custom step definition which has it's own code block.

This kind of steps also can be defined as YAML.

Example definition is shown below.

pipeline:
  stages:
    - stage: "Stage"
      steps:
        script:
          - withAnt:
            script:
              - echo "No values"
          - withEnv: "['KEY=VAL']"
            script:
              - echo $KEY
          - withCredentials: "[usernamePassword(credentialsId: 'eedc7820-a4e0-4d87-a66d-b5b65ee42ad9', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]"
            script:
              - echo $USERNAME
          - withCredentials: "[string(credentials: ''),variable: 'CRED']"
            script:
              - echo $CRED

This steps can be used within their blocks as well.

pipeline:
  stages:
    - stage: "WithEnv Intertwined"
      steps:
        script:
          - withEnv: "['KEY1=VAL1']"
            script:
              - echo env.KEY1
              - withEnv: "['KEY2=VAL2']"
                script:
                  - echo env.KEY2

Custom steps can be converted to YAML format as shown below.

myCustomStep([customVariable: '']) {
    echo "some code"
}
pipeline:
  stages:
    - stage: "Stage"
      steps:
        script:
          - myCustomStep: "[customVariable: '']"
            script:
              - echo "some code"

Conversion and Validation

Before running Pipeline As Yaml, you can convert to Declarative Script and validate the pipeline. By this, errors can be prevented before running the pipelines.

For using this functionality click the Pipeline Syntax Page which is shown in the Job Menu

Pipeline Syntax

Click "Pipeline As YAML Converter" link

Pipeline As YAML Conveter

Paste your Pipeline As YAML to first text area and click "Convert To Pipeline Declarative Script" button as shown below

Paste Pipeline

After successful conversion second text area will be filled Pipeline Declarative Script. For validation, click "Validate" button as shown below

Validate

Validation or error messages will be show below the button.

Reporting Issues

Please create issue in this repository.

Create Issue

Thank You!

If you feel your self generous today, you can buy me a coffee : )
Or you can star the project. Thanks.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].