Continuous Integration¶
DXP Cloud uses Jenkins to power its continuous integration infrastructure service. When you send a pull request or push a commit to one of your pre-configured GitHub branches, an automatic and configurable build will be triggered.
Note
DXP Cloud customers (using the customer
login) have permissions to manage and review their builds, but do not have full administrative privileges.
By default, this automated build will compile code and can be configured to execute tests. DXP Cloud will build your services and show their status on your environment’s Builds page. If the tests fail, you can check the Jenkins dashboard and logs at https://ci-companyname-infra.lfr.cloud
.
Note
Continuous integration only works if you deploy from GitHub, GitLab, or Bitbucket, not the CLI.
See the CI service limitations for more information.
Using the Default Jenkinsfile¶
Starting with CI service version liferaycloud/jenkins:2.222.1-3.2.0
, a default Jenkinsfile is available when it is not overridden. The default Jenkinsfile is always available for use for projects using version 4.x.x services.
The default Jenkinsfile encapsulates all the logic that was previously stored on the Jenkinsfile and moves it to a Jenkins plugin. This means that all bug fixes, security fixes, and improvements can be applied without requiring any CI configuration.
Apart from that, a powerful set of extension points are now provided to customize every step of the CI pipeline.
Enable the Default Jenkinsfile¶
If your project is already updated to version 4.x.x, then these steps are already complete. Otherwise, enable the default Jenkinsfile by performing the following steps:
Update your CI service to version
liferaycloud/jenkins:2.222.1-3.2.0
Delete the
Jenkinsfile
located on the root folderAdd the following environment variable:
LCP_CI_USE_DEFAULT_JENKINSFILE: true
Deploy Jenkins service
Extending the Default Jenkinsfile¶
To extend the default Jenkinsfile, you can add the following files to the ci
folder in your project repository:
Jenkinsfile-before-all
Jenkinsfile-before-cloud-build
Jenkinsfile-before-cloud-deploy
Jenkinsfile-after-all
Jenkinsfile-post-always
Here is a basic overview of the steps in the CI build process:
Load
ci/Jenkinsfile-before-all
, if it exists.Build the Liferay Workspace.
Load
ci/Jenkinsfile-before-cloud-build
, if it exists.Create the DXP Cloud build that you see in console.
Load
ci/Jenkinsfile-before-cloud-deploy
, if it exists.Optionally deploy the build to an environment in the cloud, depending on if the current branch has been specified as the deploy branch. This is configured through the
LCP_CI_DEPLOY_BRANCH
environment variable. TheLCP_CI_DEPLOY_TARGET
environment variable specifies which environment to deploy to.Load
ci/Jenkinsfile-after-all
, if it exists. This will run when all steps are done.Load
ci/Jenkinsfile-post-always
, if it exists. This will run both when the build fails and when it succeeds.
Note
If you are using version 3.x.x services, then these extensions to the Jenkinsfile are located in the lcp/ci/
folder instead. See Understanding Service Stack Versions for more information on checking the version.
To see how they are used in the default pipeline, monitor the Jenkins service startup logs. The full default Jenkinsfile is printed out in the startup logs.
Extra Pipeline Customization and External Calls¶
It is possible to use the additional steps in your pipeline to call external services. For example, you may call a third-party monitoring service through REST API, or call a script to run during the build process.
You can also create your own pipeline by defining your own Jenkinsfile
in your repository’s ci/
folder. See the Jenkins website for more information.
Warning
External services or custom pipelines should be used with discretion and are outside the scope of DXP Cloud Support. Custom Jenkins plugins are not supported.
Note
If you are using version 3.x.x services and defining your own Jenkinsfile
, then you should define it at the root of your repository instead. See Understanding Service Stack Versions for more information on checking the version.
Reusing Code Between Different Extension Points¶
You will likely want a way to share code between these extension points. One basic way is to load a groovy script. For example, you could create a groovy file in the ci/
folder called util.groovy
with these contents:
def sendSlackMessage(message) {
println(message)
}
return this
Then you could insert the following in ci/Jenkinsfile-before-cloud-build
:
def util = load("ci/util.groovy")
util.sendSlackMessage("About to create DXP Cloud build...")
Note
If you are using version 3.x.x services, then these files instead belong in the lcp/ci/
directory in the repository. See Understanding Service Stack Versions for more information on checking the version.
Environment Variables Reference¶
The following environment variables are only used in the default Jenkinsfile. To see what they do please refer to Jenkins documentation regarding pipeline options.
Name |
Default Value |
Description |
---|---|---|
|
|
Number of days that artifacts are stored |
|
|
Set the number of recent builds for which artifacts and stashes are preserved. |
|
|
Number of days that builds are stored |
|
|
Number of builds that are stored |
|
|
Set a timeout period for the Pipeline run, after which Jenkins should abort the Pipeline |
|
Branch used for automatic deployment. If this variable is not set to a valid branch name, then automatic deployment is disabled. |
|
|
Sets the environment automatic deployment will deploy to. Only used if |
|
|
Comma-delimited list of hotfixes for CI to apply automatically when deploying the Liferay service. Replace |
|
|
|
Set the number of recent builds for which stashes are preserved. Stashes cannot be preserved for more builds than allowed by the |
|
|
Option to enable or disable automatic web hook management for code hosting platforms (such as GitHub). |
|
|
Sets which source control management service is used for retrieving builds. Accepted values are |
|
Sets the repository name used to retrieve builds (from GitHub, Bitbucket, or GitLab). |
|
|
The repository owner used to retrieve builds. |
|
|
The personal access token needed to access and retrieve builds from Bitbucket, GitHub, or GitLab. |
|
|
|
Option to enable or disable the Default Jenkinsfile |
|
The host name of the Database service. |