Build Triggers - Scripted Pipeline Syntax

JFrog Integrations Documentation

Content Type

The Artifactory Trigger allows a Jenkins job to be automatically triggered when files are added or modified in a specific Artifactory path. The trigger periodically polls Artifactory to check if the job should be triggered. You can read more about it here.

You have the option of defining the Artifactory Trigger from within your pipeline. Here's how you do it:

Start by creating an Artifactory server instance, as described at the beginning of this article.

Here's an example:

def server = Artifactory.server 'my-server-id'

Next, set the trigger as follows:

server.setBuildTrigger spec: "*/10 * * * *", paths: "generic-libs-local/builds/starship" 

When a job is triggered following deployments to Artifactory, you can get the URL of the file in Artifactory which triggered the job. Here's how you get it:

def url = currentBuild.getBuildCauses('org.jfrog.hudson.trigger.ArtifactoryCause')[0]?.url

If the cause of the job triggering is different, the url value will be empty.