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

From Gcube Wiki
Jump to: navigation, search
(Parameters)
(Git Repository)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= gCubeActions Pipeline Project =
 
= gCubeActions Pipeline Project =
A pipeline to execute configurable actions over a list of Git repositories:
+
A pipeline to execute configurable actions over a list of Git repositories.
  
 
The pipeline project is available at: https://jenkins.d4science.org/job/Pipeline-gCubeActions/
 
The pipeline project is available at: https://jenkins.d4science.org/job/Pipeline-gCubeActions/
 
  
 
== Parameters==
 
== Parameters==
Line 9: Line 8:
 
* Git Root: The URL of the parent organization that includes all the listed repositories.
 
* Git Root: The URL of the parent organization that includes all the listed repositories.
 
* List of Repositories: A plain text file, one line for each Git repository name to update.
 
* List of Repositories: A plain text file, one line for each Git repository name to update.
* Action Root: The root URL of the Bash fragment to execute.
+
* Action Root: The root URL of the Bash script to execute.
* Action File: The relative path under the Action Root of a Bash script  
+
* Action File: The relative path under the Action Root of a script to execute.
  
 
Example:
 
Example:
Line 16: Line 15:
 
[[File:Jenkins_action_pipeline_params.png|800px]]
 
[[File:Jenkins_action_pipeline_params.png|800px]]
  
== Triggers ==
+
=== Sample Action ===
No triggers are defined because the pipeline is expected to be manually launched by the [[Continuous_Integration:_Releases_Manager|Release Manager]].
+
The following Action adds the LICENSE.md file to the Git repository:
 +
<pre>
 +
#!/usr/bin/env bash
 +
if [[ ! -f LICENSE.md ]]; then
 +
    curl <my URL>/LICENSE.md -o LICENSE.md
 +
    git add LICENSE.md
 +
    git commit -m "Add LICENSE.md."
 +
fi
 +
</pre>
  
== Git ==
+
== How does it work ==
The pipeline is maintained in a Git repository. This section connects the project to the Git repository.
+
Upon passing valid parameters, the pipeline performs the following steps:
  
[[File:Jenkins_tagging_pipeline_git.png|800px]]
+
1. clones one repository at the time from <code>Git Root/Repo Name</code>
 +
 
 +
2. downloads the action file from <code>Action Root/Action File</code> in the root folder of the repository
 +
 
 +
3. runs the action file using the root folder of the repository as working dir
 +
 
 +
4. pushes the repository back to Gitea
 +
 
 +
Every change to the Git repository **MUST** be done by the action file. The pipeline is in charge only
 +
to push the repository to the remote origin.
 +
 
 +
== Triggers ==
 +
No triggers are defined because the pipeline is expected to be manually launched by the [[Continuous_Integration:_Releases_Manager|Release Manager]].
  
 
= Jenkins Pipeline Definition =
 
= Jenkins Pipeline Definition =
 
== Git Repository ==
 
== Git Repository ==
The definition of the gCube release pipeline is maintained in this Git Repository: ...
+
The definition of the gCube release pipeline is maintained in this Git Repository: https://code-repo.d4science.org/gCubeCI/gCubeActionExecutor
 +
 
 +
Actions and repo lists are defined in this Git repository: https://code-repo.d4science.org/gCubeCI/gCubeActions. But in theory, they could be stored in any location accessible via HTTP/HTTPS.
  
 
== Requirements on Jenkins ==
 
== Requirements on Jenkins ==
Line 39: Line 60:
 
= Jenkins Pipeline Execution =
 
= Jenkins Pipeline Execution =
  
 +
Given the following list of repositories:
 +
<pre>
 +
to_update_1
 +
to_update_2
 +
to_update_3
 +
</pre>
 +
 +
the execution page will look like the following:
 +
 +
[[File:Jenkins_action_pipeline_execution.png|600px]]
  
 
= Action Report =
 
= Action Report =
If the pipeline execution succeeds, it sends a tag report to the release manager.
+
If the pipeline execution succeeds, it sends a report to the release manager.
The report includes the following information for each Git repository tagged:
+
 
* the repo name
+
The report includes the following information for each Git repository where the action was executed:
* the SCM url
+
* repo name
* the result (completed or failed)
+
* SCM url
 +
* result (completed or failed)
  
 
Here's an example of a tag report:
 
Here's an example of a tag report:
  
[[File:Jenkins-action-report.png|600px]]
+
[[File:Jenkins-action-report.png|400px]]
 
   
 
   
 
''Back to the [[Continuous_Integration_procedure_(2019) | CI guide]].''
 
''Back to the [[Continuous_Integration_procedure_(2019) | CI guide]].''
  
 
[[Category:Continuous_Integration]]
 
[[Category:Continuous_Integration]]

Latest revision as of 15:57, 27 January 2021

gCubeActions Pipeline Project

A pipeline to execute configurable actions over a list of Git repositories.

The pipeline project is available at: https://jenkins.d4science.org/job/Pipeline-gCubeActions/

Parameters

  • Git Root: The URL of the parent organization that includes all the listed repositories.
  • List of Repositories: A plain text file, one line for each Git repository name to update.
  • Action Root: The root URL of the Bash script to execute.
  • Action File: The relative path under the Action Root of a script to execute.

Example:

Jenkins action pipeline params.png

Sample Action

The following Action adds the LICENSE.md file to the Git repository:

#!/usr/bin/env bash
if [[ ! -f LICENSE.md ]]; then
    curl <my URL>/LICENSE.md -o LICENSE.md
    git add LICENSE.md
    git commit -m "Add LICENSE.md."
fi

How does it work

Upon passing valid parameters, the pipeline performs the following steps:

1. clones one repository at the time from Git Root/Repo Name

2. downloads the action file from Action Root/Action File in the root folder of the repository

3. runs the action file using the root folder of the repository as working dir

4. pushes the repository back to Gitea

Every change to the Git repository **MUST** be done by the action file. The pipeline is in charge only to push the repository to the remote origin.

Triggers

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

Jenkins Pipeline Definition

Git Repository

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

Actions and repo lists are defined in this Git repository: https://code-repo.d4science.org/gCubeCI/gCubeActions. But in theory, they could be stored in any location accessible via HTTP/HTTPS.

Requirements on Jenkins

Jenkins Pipeline Execution

Given the following list of repositories:

to_update_1
to_update_2
to_update_3

the execution page will look like the following:

Jenkins action pipeline execution.png

Action Report

If the pipeline execution succeeds, it sends a report to the release manager.

The report includes the following information for each Git repository where the action was executed:

  • repo name
  • SCM url
  • result (completed or failed)

Here's an example of a tag report:

Jenkins-action-report.png

Back to the CI guide.