How can I introduce a conditional in my Jenkinsfile that is executed when requirements.txt has been changed in the current pull request?

Hi there, I am quite new to writing code in Jenkinsfile so please excuse me if this is basic.

I am trying to execute a function, if the requirements.txt file has been changed in the current pull request.

Here is the code that I have:

> ...
stage('Create Jira Ticket') {
        when {
            anyOf {
                changeset 'requirements.txt'
            }
        }
        steps{
            jiraTicketCreator()  // this function is defined higher up
        }
    }

But when I run a build for the above, without any changes to the requirements.txt file, the function is still called.

Hi I think this will help:

1 Like

I realised all I was missing was changeset '**/requirements.txt'