Issue
Please suggest a plugin or an approach to achieve the following in Jenkins declarative pipeline.
Solution
You don't need any plugin per se, as you can use e.g. curl
:
def calendar_url = "https://calendarific.com/api/v2/holidays?&api_key=758f54db8c52c2b500c928282fe83af1b1aa2be8&country=IN&year=2020"
def curl_output = sh returnStdout: true, script: "curl -s ${calendar_url}"
You can convert it to json with readJson utility:
def holidays = readJson text: curl_output
for (holiday in holidays.response.holidays) {
def holiday_date = holiday.date.iso
println holiday_date
}
Defining the current date and bailing out of the build is left as an exercise for the implementor :)
Answered By - MaratC
Answer Checked By - Cary Denson (JavaFixing Admin)