Difference between revisions of "Continuous Integration: Releases Jenkins Pipeline"

From Gcube Wiki
Jump to: navigation, search
(Basic Structure)
(Basic Structure)
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  
  
[https://jenkins.io/doc/book/pipeline/| Jenkins Pipeline] is a combination of plugins that support the integration and implementation of continuous delivery pipelines using Jenkins. A pipeline has an extensible automation server for creating simple or complex delivery pipelines "as code," via pipeline DSL (Domain-specific Language).
+
[https://jenkins.io/doc/book/pipeline/ Jenkins Pipeline] is a combination of plugins that support the integration and implementation of continuous delivery pipelines using Jenkins. A pipeline has an extensible automation server for creating simple or complex delivery pipelines "as code," via pipeline DSL (Domain-specific Language).
  
 
= gCubeRelease Pipeline Project =
 
= gCubeRelease Pipeline Project =
Line 11: Line 11:
 
[[File:Jenkins_pipeline_params.png|800px]]
 
[[File:Jenkins_pipeline_params.png|800px]]
 
== Triggers ==
 
== Triggers ==
No triggers are defined because the pipeline is designed to be manually launched by the [[Continuous_Integration:_Releases_Manager|Release Manager]]:
+
No triggers are defined because the pipeline is expected to be manually launched by the [[Continuous_Integration:_Releases_Manager|Release Manager]]:
  
 
[[File:Jenkins_pipeline_triggers.png|400px]]
 
[[File:Jenkins_pipeline_triggers.png|400px]]
 +
 +
It can be changed according to the release needs and the availability of a sufficient number of dedicate agents in Jenkins.
  
 
== Git ==
 
== Git ==
 
The [[Continuous_Integration:_Releases_Jenkins_Pipeline#Jenkins_Pipeline_Definition| pipeline definition]] is maintained in a Git repository. This section connects the project to the Git repository.
 
The [[Continuous_Integration:_Releases_Jenkins_Pipeline#Jenkins_Pipeline_Definition| pipeline definition]] is maintained in a Git repository. This section connects the project to the Git repository.
 +
 
[[File:Jenkins_pipeline_git.png|800px]]
 
[[File:Jenkins_pipeline_git.png|800px]]
  
 
= Jenkins Pipeline Definition =
 
= Jenkins Pipeline Definition =
 
== Git Repository ==
 
== Git Repository ==
The definition of the gCube release pipeline is maintained in this Git Repository: https://code-repo.d4science.org/gCubePipelines/gCubeRelease
+
The definition of the gCube release pipeline is maintained in this Git Repository: https://code-repo.d4science.org/gCubeCI/gCubeRelease
  
 
== Requirements==
 
== Requirements==
Line 29: Line 32:
 
* [https://plugins.jenkins.io/pipeline-maven| Pipeline: Maven]
 
* [https://plugins.jenkins.io/pipeline-maven| Pipeline: Maven]
 
* Jenkins configured with a JDK named 'OpenJDK 8'
 
* Jenkins configured with a JDK named 'OpenJDK 8'
 +
* One or more Jenkins agents labeled as 'pipeline-agent'
  
 
== Basic Structure ==
 
== Basic Structure ==
[https://code-repo.d4science.org/gCubePipelines/gCubeRelease/src/branch/master/Jenkinsfile|''Jenkinsfile''] defines a [https://jenkins.io/doc/book/pipeline/#declarative-pipeline-fundamentals| Declarative Pipeline].
+
[https://code-repo.d4science.org/gCubeCI/gCubeRelease/src/branch/master/Jenkinsfile ''Jenkinsfile''] defines a [https://jenkins.io/doc/book/pipeline/#declarative-pipeline-fundamentals Declarative Pipeline]. The Pipeline’s code defines the entire build process of a gCube Release.
  
This is a stub of the gCubeRelease pipeline.
+
This is the stub of the gCubeRelease pipeline.
  
 
<pre>
 
<pre>
Line 41: Line 45:
 
   // pipeline
 
   // pipeline
 
   pipeline {
 
   pipeline {
         // no restriction
+
         // run only on agents with the label
         agent any
+
         agent { label 'pipeline-agent' }
  
 
         // expected input parameters
 
         // expected input parameters
Line 54: Line 58:
 
               //prepare the environment for the builds
 
               //prepare the environment for the builds
 
                 steps {
 
                 steps {
                    script {
+
                      //execute steps here if needed
                        //execute shell commands if needed
+
                    }
+
 
                 }
 
                 }
 
             }
 
             }
Line 67: Line 69:
 
                       build 'job name 4'
 
                       build 'job name 4'
 
                     }
 
                     }
                     script {
+
                     echo 'Done with group 1'
                        //execute shell commands if needed
+
                    }
+
 
                 }
 
                 }
 
             }
 
             }
Line 103: Line 103:
 
== Reference Documentation ==
 
== Reference Documentation ==
  
[https://jenkins.io/doc/book/pipeline/syntax/| Pipeline Syntax]
+
[https://jenkins.io/doc/book/pipeline/syntax Pipeline Syntax]
  
  
 
''Back to the [[Continuous_Integration_procedure_(2019) | CI guide]].''
 
''Back to the [[Continuous_Integration_procedure_(2019) | CI guide]].''
 +
 +
[[Category:Continuous_Integration]]

Revision as of 17:39, 9 July 2019


Jenkins Pipeline is a combination of plugins that support the integration and implementation of continuous delivery pipelines using Jenkins. A pipeline has an extensible automation server for creating simple or complex delivery pipelines "as code," via pipeline DSL (Domain-specific Language).

gCubeRelease Pipeline Project

In gCube we use a Pipeline to trigger the builds of jobs forming a gCube Release. The pipeline project is available at: https://jenkins.d4science.org/job/gCube-Release/

Parameters

Jenkins pipeline params.png

Triggers

No triggers are defined because the pipeline is expected to be manually launched by the Release Manager:

Jenkins pipeline triggers.png

It can be changed according to the release needs and the availability of a sufficient number of dedicate agents in Jenkins.

Git

The pipeline definition is maintained in a Git repository. This section connects the project to the Git repository.

Jenkins pipeline git.png

Jenkins Pipeline Definition

Git Repository

The definition of the gCube release pipeline is maintained in this Git Repository: https://code-repo.d4science.org/gCubeCI/gCubeRelease

Requirements

Basic Structure

Jenkinsfile defines a Declarative Pipeline. The Pipeline’s code defines the entire build process of a gCube Release.

This is the stub of the gCubeRelease pipeline.

  
  // manage options and settings

  // pipeline
  pipeline {
        // run only on agents with the label
        agent { label 'pipeline-agent' }

        // expected input parameters
        parameters {
            string(name: 'myInput', description: 'Some pipeline parameters')
        }


        stages {
            stage('preliminary steps') {
               //prepare the environment for the builds
                steps {
                       //execute steps here if needed
                }
            }
            stage('build group 1') {
                steps {
            	   withMaven(..maven settings here..) {
                       build 'job name 1'
                       build 'job name 2'
                       build 'job name 3'
                       build 'job name 4'
                    }
                    echo 'Done with group 1'
                }
            }
            stage('build group 2') {
                steps {
                    ...
                }
            }
        }
	// post-build actions
	post {
		always {
			echo 'This will always run'
		}
		success {
			echo 'This will run only if successful'
		}
		failure {
			echo 'This will run only if failed'
		}
		unstable {
			echo 'This will run only if the run was marked as unstable'
		}
		changed {
			echo 'This will run only if the state of the Pipeline has changed'
			echo 'For example, if the Pipeline was previously failing but is now successful'
		}
	}

    }

Reference Documentation

Pipeline Syntax


Back to the CI guide.