Jenkins plugin
The Perfecto Jenkins plugin provides the ability to auto-create or re-use an existing Perfecto Connect tunnel ID in the build environment.
On this page:
Prerequisites
Before you enable the plugin, make sure you:
- Download the Perfecto Connect client and extract it to any folder.
- Generate a Perfecto security token (if you do not have one already).
- Install Jenkins via brew if you are a Mac user.
- Perform the following steps as an administrator of the Jenkins environment:
In Jenkins, in the Manage Jenkins > Manage Plugins view, select the Available tab.
In the search field, enter perfecto to search for the Perfecto plugin.
To the left of the Perfecto plugin, select the checkbox. Then click Install without restart.
Step-by-step instructions
Click a step to view details.
Perform the following steps to enable the plugin in Jenkins.
To enable the plugin:
-
On the Jenkins homepage, in the left pane, click New Item.
- In theEnter an item namefield, specify the name for your new item.
- Select any project type except pipeline.
- Click OK.
-
Under Build Environment, do the following:
- Select the Perfecto Connect checkbox. You may need to get help from your Jenkins Administrator to create the Perfecto credentials
- Next to the Credentials list, click Add and then select Jenkins.
-
In the Add Credentials dialog box, do the following:
- From the Kind list, select Perfecto.
- Provide your cloud name, username, and Perfecto security token.
- Click Add.
- From the Credentials list, select the credentials you added.
- In the Perfecto Connect Path field, provide the path to Perfecto Connect, such as
/Users/Mymac/Downloads
on Mac. - In the Perfecto Connect File Name field, provide the file name of the Perfecto Connect executable, such as
perfectoconnect
on Mac orperfectoconnect64.exe
orperfectoconnect32.exe
on Windows. -
(Optional) Click Advanced to set advanced Perfecto Connect configuration options, as follows:
-
In the Additional Parameters field, provide additional Perfecto Connect parameters, such as
bridgeproxyip
andbridgeproxyport
. For example:Copy- --bridgeproxyip=127.0.0.1 --bridgeproxyport=8888
For more information, see Work with Perfecto Connect.
- To override the name of the Tunnel ID environment variable, in the Override Tunnel ID Name field, provide a different name.
- To reuse a Tunnel ID already created earlier, in the Existing Tunnel ID field, provide the existing ID.
-
This section illustrates how to connect to Perfecto Connect with Maven and Gradle.
Connect with Maven
To connect to Perfecto Connect with Maven, specify the following information for the build:
-
Root POM: pom.xml
-
Goals and options:
clean install -DtunnelId=${tunnelId]
Connect with Gradle
To connect to Perfecto Connect with Gradle, specify the following information for the build:
-
Select Invoke Gradle.
-
Specify the Gradle Version as
GRADLE_HOME
.
- Under Post-build Actions, add a post-build task.
-
In the Script field, enter the following script:
Copy/<path to Perfecto Connect>/<name of Perfecto Connect executable> stop
For example:
You may want to use the following independent and alternate practices in combination with the Jenkins plugin, in particular how to create a Jenkins pipeline with Perfecto Connect and how to upload a file to the Perfecto media repository.
Create a Perfecto Connect pipeline
-
Create a new pipeline and add the below code to the Pipeline Script field:
Copyimport javax.swing.GroupLayout.ParallelGroup
import groovy.json.JsonSlurperClassic
import groovy.json.JsonSlurper
node {
String cloudName = "<<CLOUD NAME e.g. demo>>";
String securityToken = "<<SECURITY TOKEN>>";
String perfectoConnectPath = "/Users/myMac/Downloads/perfectoconnect";
environment {
tunnelId = "" }
stage('perfectoconnect start'){
if(cloudName.contains("<<")){
error "Kindly update cloudName, securityToken and perfectoConnectPath" }
String script = perfectoConnectPath + " start -c " + cloudName + ".perfectomobile.com -s " + securityToken;
echo script;
tunnelId = sh (script: script , returnStdout: true).trim()
env.tunnelId = "${tunnelId}" }
stage('script'){
echo "Tunnel id: ${tunnelId}" }
stage('perfectoconnect stop'){
sh label: '', returnStdout: true, script: perfectoConnectPath + " stop" }
} - In the script, update the
cloudName
,securityToken
, andperfectoConnectPath
as applicable.
Upload the app to Perfecto
To upload the app to the Perfecto media repository, see Upload Item to Repository.