Configuring Your Azure Repository
Your Liferay Cloud onboarding email contains a link to a GitHub repository hosted in the dxpcloud
organization. This repository is a template for a team’s private Liferay Cloud development repository and is typically removed after 10 business days. Users must transfer the provisioned repository to their own private repository.
The provisioned GitHub repository can be transferred to an Azure repository as of version 3.2.0 of the Jenkins service. This must be done with administrative access to the Azure repository.
The repository’s administrators are not necessarily the same as your project’s administrators in the Cloud console.
Preparing the Jenkins Service
If you’ve customized your Jenkinsfile, follow this guide to extend the default Jenkinsfile.
Importing from GitHub to Azure
-
Go to Azure DevOps.
-
Click New project.
-
Provide a name for the project.
-
Ensure the visibility is set to private.
-
Click Repos in the side navigation.
-
Click Import under Import a repository.
-
Insert the GitHub repository’s URL into Clone URL.
-
Select Requires Authentication.
-
Fill out the Username and Password/PAT fields and click Import.
-
In the terminal, clone the provisioned GitHub repository locally:
git clone git@github.com:dxpcloud/example.git
NoteIf you have already cloned the repository to work with another provider, you can skip this step and work within the same clone.
-
Add a new Git remote and point to Azure:
git remote add azure ORGANIZATION@dev.azure.com:ORGANIZATION/PROJECTNAME/_git/PROJECTNAME
-
Push the cloned repository to the new remote repository:
git push azure master
If you need help creating, cloning, and pushing repositories, see Azure’s documentation.
Generating Access Tokens for Azure
Next, create an access token that to be used by the Webhook to trigger Jenkins builds:
-
Navigate to the personal access tokens page.
-
Click New Token.
-
Provide a name and an expiration date for this token.
-
Configure the access token to have the permission below:
- Code: Read
Connecting Azure to Your Jenkins Service
Lastly, set environment variables in the Jenkins service’s to point to your new repository:
-
Log into the Liferay Cloud Console and navigate to your Jenkins service in the
infra
environment. -
Navigate to the Environment Variables tab.
-
Configure the following environment variables:
Name | Value |
---|---|
LCP_CI_SCM_PROVIDER | azure-devops |
LCP_CI_SCM_REPOSITORY_OWNER | [repo owner] |
LCP_CI_SCM_REPOSITORY_NAME | [repo name] |
LCP_CI_SCM_TOKEN | [access token] |
For added security, store the value of LCP_SI_SCM_TOKEN
in a secret variable.
After updating these environment variables, the Jenkins service restarts. Jenkins checks the repository every 5 minutes and triggers builds for pushed branches.
Verifying Builds
Pushed branches trigger builds that you can see or deploy from the Builds tab in the Liferay Cloud Console. After setting up integration with the Jenkins service, a good next step is to verify these builds, to ensure that the integration was successful. Verify that new Git pushes trigger Jenkins builds:
-
Make a change to the repository (like adding a file), then commit it to the branch:
git commit -m "Add file to test builds"
-
Push the branch up to Azure DevOps:
git push azure branch-name
-
Navigate to the Builds page in the Liferay Cloud Console.
-
Verify that the build displays for the pushed branch on the Builds page. This might take up to 5 minutes.