Trigger Jenkins Jobs from AIO Tests

AIO Tests now supports the ability to trigger Jenkins jobs directly from within the application, allowing seamless integration between your test management process and your CI/CD pipeline. This feature enables users to automate job execution and retrieve results without switching contexts.

To proceed with the same, you can set up a CI/CD system to connect to your Jenkins instance within AIO Tests. Post declaring your CI/CD system, you can setup AIO jobs which map to the Jenkins jobs.

Steps to get started:

1. Setting up a CI/CD system

While you are within AIO Tests App, navigate to the Cycles screen, click on the CI icon as shown below.

image-20241203-141732.png

Click on Setup CI/CD system

 

image-20241203-141917.png

Create a CI/CD system in AIO by entering a user-friendly name and Host URL of your Jenkins instance (the endpoint where your Jenkins is hosted).

Note: the system should be accessible from outside network.  Only valid URLs with https:// are supported.  

Step 1 is now complete.

2. Setup Credentials

Once your system is created, you can now add system credentials.
Note that before configuring a job, you will be prompted to add system credentials unless it is setup.

Navigate to to My settings > CI/CD Credentials > Add System Credential

If systems are not created, then step 1 needs to be done. Once a system is created, a credential can be seutp for it. Make sure to use the API token that you wish to use for Jenkins and not passwords.

Jenkins API token can be generated from User Profile → Configure

Note: CI/CD credentials are 1 per system shown in my settings, if token is changed in Jenkins, you need to change in AIO Tests.

3. Connect to Jenkins Job

Once you add a valid system credential, you can now Configure/Add New Jobs, edit system name, check error logs and delete systems.

Simply Click on the (CI) icon on the right and you should get a prompt referral image below:

To Configure/Add New job, click on the icon (blue arrow) and you will be able to see the Jobs from Jenkins.
Select one as per your convenience, and all the Job Parameters (screenshot below) will be auto populated from the Jenkins jobs. Parameters of type File and Credentials cannot be set from within AIO and defaults will be used in the jobs.

In the below example, you can see AttachFile-Job and its relevant parameters that are already present in Jenkins will be shown here at AIO Tests app.

On the right-hand side you can see a “Convert to AIO field” icon, for string type parameters. Once you click on it, you can change it to AIO field.

Changing to AIO field will allow you to use the fields like Project_Key, Cycle Key, Case Key List etc. These fields will be filled with data by AIO Tests automatically when the job is triggered. This process can be reverted – if you click on the interchange icon again will allow you to add text.

Sample Job Parameters from Jenkins (screenshot below)

Authentication options:

Job Executor Credentials: Whoever is triggering the job, they can use their credentials irrespective of who has created the job.

User Credentials: A specific user can share his/her credential and only that can be used to trigger the jobs. Users setting up the job or editing the job can basically share their credentials for execution with the team.

Custom Credentials: Any automation user from the team can use their credentials, it can be used for all the jobs. This can be helpful if team uses a shared automation user.

4. Triggering Jobs

Once jobs are setup, they can be triggered from either the Cycle view or the Cycle Listing view. Click on the CI button on either of the screens.

Select the job to be triggered and click on the Trigger button.

Modify/add the required parameters for the build and click on the Trigger button.

If the job trigger is successful, you should see a 201 message that says success under Logs (referral image Yellow Arrow)

Logs help you understand the status of the jobs triggered in the last 30 days. It gives you a detailed view of error codes, trigger date, triggered by whom and detailed insights on Job Request as well as Response code.

 

Note: Some typical codes that you might receive are as follows.
403 Forbidden: Authentication error
201: Authentication successful
500: Server error

On the Jenkins section, you can now check on the build section or search by the name of the Job – (Example Attachfile-Job in this case) and it should be visible.

 

 

Important Considerations

  1. Authentication and Permissions:

    • If Jenkins credentials are saved using username and password instead of an API token, users will only have read-only access to job data and will not be able to trigger jobs.

      You will get a 403 Forbidden error, if you use password instead of API token in AIO Tests CI/CD System

  2. Network Accessibility:

    • Jenkins must be accessible to external network calls for AIO Tests to trigger jobs. Ensure that your network settings or firewalls do not block these requests.

  3. Job Queue Handling:

    • If a Jenkins job is already in the queue, triggering it again will result in a 404 error. This is inherent to Jenkins' behavior and not an issue with AIO Tests.

  4. Updating AIO Test Jobs After Jenkins Changes:

    • If any changes are made to a Jenkins job configuration, update the corresponding AIO Test job to ensure smooth execution and reporting without errors.


Troubleshooting and Support

  • For any queries or issues related to Jenkins integration, contact our support team at help@aiotests.com.