Configuring Jenkins
Learn how to configure Jenkins for secure CI/CD workflows.
Abstract
Preface Copy linkLink copied to clipboard!
To enable your Jenkins pipeline to perform essential tasks, such as vulnerability scanning, image signing, and attestation, follow these steps. The table outlines the actions you need to take and when you need to complete them.
| Action | When to complete |
|---|---|
| Adding secrets to Jenkins for secure integration with external tools | Before you use secure software templates to create an application, add secrets to Jenkins. This ensures seamless integration with ACS, Quay, and GitOps. |
| Add your application to Jenkins | After creating the application and source repositories, add them to Jenkins. This enables you to review various aspects of the Jenkins pipeline on the Red Hat Developer Hub platform. |
By completing these steps, you enable Jenkins to integrate seamlessly with ACS (Advanced Cluster Security), Quay, and GitOps, and utilize Cosign for signing and verifying container images.
Chapter 1. Adding secrets and environment variables to Jenkins for integration with external tools Copy linkLink copied to clipboard!
When you select Jenkins as your CI provider while creating an application, you must add secrets and environment variables to Jenkins for secure integration with external tools. This enables Jenkins to perform essential tasks, such as vulnerability scanning, image signing, and attestation generation.
Prerequisites
- You must have the necessary permissions to create and manage Jenkins jobs, variables, and CI pipelines.
- You must have the username and password for the image registry, such as Quay.io, Jfrog Artifactory, or Sonatype Nexus.
- You must have appropriate GitOps credentials.
You must have the following information for specific tasks that you want Jenkins pipeline to perform:
For ACS tasks:
- ROX Central server endpoint and token
For SBOM tasks:
- Cosign signing key password, private key, and public key
- Trustification API and issuer URL, client ID, client secret, and supported CycloneDX version
NoteThe values used for these credentials are already Base64-encoded, so you do not need to convert them. You can find these credentials in your
private.envfile.
1.1. Adding secrets to Jenkins Copy linkLink copied to clipboard!
Follow the procedure to add required credentials using UI on the Jenkins server.
Procedure
- Open your Jenkins instance in a web browser and log in with your admin credentials.
- Select your username at the top right corner of the Jenkins dashboard.
- From the left sidebar, select Manage Jenkins.
- In the Security section select Credentials.
- Under Stores scoped to Jenkins select System.
- Choose a domain where you want to add the credentials. Typically, it’s Global credentials (unrestricted), click this domain name.
- Select Add Credentials.
- From the Kind drop-down list, select Secret text.
- Keep the default value in the Scope drop-down list as Global (Jenkins…).
- Enter information related to your secret in the UI fields.
- Select Create.
Repeat steps 7-11 to add the following credentials:
NoteFor image registries, Quay is the default option. To use JFrog Artifactory or Sonatype Nexus, uncomment lines with corresponding variables in 2 Jenkinsfiles in both the gitops-template and source-repo folders in your cloned tssc-sample-templates GitHub repository.
Expand Table 1.1. Image registry and GitOps secrets Variable Description QUAY_IO_CREDSUsername and password for accessing your Quay.io repository. This is the default option that is uncommented in Jenkinsfiles.
ARTIFACTORY_IO_CREDSUsername and password for accessing your JFrog Artifactory repository.
NEXUS_IO_CREDSUsername and password for accessing your Sonatype Nexus repository.
GITOPS_AUTH_PASSWORDThe token the system uses to update the GitOps repository for newly built images.
Expand Table 1.2. Secrets required for ACS and SBOM tasks Variable Description ROX_API_TOKENAPI token for accessing the ROX server.
COSIGN_SECRET_PASSWORDPassword for Cosign signing key.
COSIGN_SECRET_KEYPrivate key for Cosign.
TRUSTIFICATION_OIDC_CLIENT_SECRETClient secret used alongside the client ID to authenticate to the Trustification Bombastic API.
Rerun the last pipeline run.
- Alternatively, switch to you application’s source repository in GitHub, make a minor change, and commit it to trigger a new pipeline run.
1.2. Adding environment variables to Jenkins Copy linkLink copied to clipboard!
After adding all required secrets, follow this procedure to add the environment variables using UI on the Jenkins server.
Procedure
- From the left sidebar, select Manage Jenkins.
- In the System Configuration section select System.
- On the System page scroll down to find the Global properties section.
- Select Environment variables > Add
Add key-value pairs for the following environment variables:
Expand Table 1.3. GitOps variable Variable Description GITOPS_AUTH_USERNAME(optional)The variable required for Jenkins to work with GitLab.
Expand Table 1.4. Variables required for ACS and SBOM tasks Variable Description ROX_CENTRAL_ENDPOINTEndpoint for the ROX Central server.
COSIGN_PUBLIC_KEYPublic key for Cosign.
TRUSTIFICATION_BOMBASTIC_API_URLURL for Trustification Bombastic API used in SBOM generation.
TRUSTIFICATION_OIDC_ISSUER_URLOIDC issuer URL used for authentication when interacting with the Trustification Bombastic API.
TRUSTIFICATION_OIDC_CLIENT_IDClient ID for authenticating to the Trustification Bombastic API using OIDC.
TRUSTIFICATION_SUPPORTED_CYCLONEDX_VERSIONSpecifies the CycloneDX SBOM version that is supported and generated by the system.
Optional: Set the Rekor and TUF variables if Jenkins doesn’t run on a local OpenShift instance, and the Rekor and TUF services are on different clusters. Also, uncomment lines with Rekor and TUF variables in a Jenkinsfile in your cloned tssc-sample-templates repository.
Expand Table 1.5. Rekor and TUF variables Variable Description REKOR_HOSTURL of your Rekor server.
TUF_MIRRORURL of your TUF service.
- When you added all variables, select Save.
- Rerun the last pipeline run.
Chapter 2. Adding your application to Jenkins Copy linkLink copied to clipboard!
When you select Jenkins as your CI provider while creating an application, you must add your application to Jenkins. Proper integration ensures that your pipeline aligns with your CI/CD workflows and operates seamlessly.
Prerequisites
- You must have installed and configured Jenkins in your environment.
- You must have the necessary permissions to create and manage Jenkins jobs.
- You must have added correct credentials for the Jenkins pipeline during the post RHTAP install phase.
-
Review the
Jenkinsfileand ensure it aligns with your Jenkins configuration. For example, you may need to update the agent settings to limit where the pipeline can run. -
Ensure that the Jenkins agent has the necessary binaries installed:
git,curl,jq,yq,buildah,syft,cosign,python3, andtree. If the pipeline run fails at the start, it likely indicates that one or more binaries are missing.
Procedure
- Log in to your Jenkins instance.
- From the Jenkins dashboard, select New Item.
Enter a name for your pipeline job and select Pipeline project (for example,
secure-jenkins).NoteThe name of your pipeline job must match the name of the application for which you are adding Jenkins CI. If the names do not match, the pipeline will run on Jenkins but will not be visible on RHDH.
-
(Optional) If you want to use a different pipeline name, update the
jenkins.io/job-full-namefield in thecatalog-info.yamlfile in the source repository with the pipeline name you choose.
-
(Optional) If you want to use a different pipeline name, update the
- Select OK to create the job.
- On the Configure > General page, navigate to the Pipeline section, and from the Definition drop-down list, select Pipeline script from SCM.
- From the SCM drop-down list, select Git.
In the Repository URL field, enter the Jenkins source repository URL.
- On the Red Hat Developer Hub platform, from the Catalog, select an appropriate application.
- Go to the Overview tab and select View Source to open the repository where your application’s source code is housed.
-
In the Branches to build section, enter
*/main. - Select Save. The system displays the live-jenkins (name of your job) page.
Select Build Now. The system starts the build pipeline. Wait until the build is complete.
- In the Stage View section, select Pipeline Overview to visualize the pipeline run.
- Select Pipeline Console to review the live logs of each stage of the pipeline run.
Verification
After integrating your application with Jenkins, review various aspects of the Jenkins pipeline on the Red Hat Developer Hub platform.
From the Catalog, select the appropriate application or component.
- Go to the CI tab to view the Jenkins project. For the appropriate Jenkins job, using the Actions column, you can view, rerun, and view history of the job. The system displays the job overview with the status of latest run.
- Go to the CD tab and select the appropriate card to view deployment details, such as the commit message, author name, and deployment history managed by ArgoCD and GitOps.
- In the Catalog, from the Kind dropdown list, select Resource. The system displays Jenkins GitOps jobs. Select and review the appropriate GitOps resource.
- Go to the Topology tab to visualize your application’s deployment within the development namespace.
Completing these steps ensures seamless integration of your application with Jenkins, enabling efficient and reliable CI/CD workflows.
Revised on 2025-04-30 03:55:47 UTC