In some of my workflows, I check the return code from a policy that is executed before continuing. If the policy fails, it will attempt to run the policy again, etc. Here are a couple of examples of how I check the return code:
# Example 1: for ((i=0; i<=3; i++)); do if /usr/local/jamf/bin/jamf policy -event "$event"; then echo "Success" break else echo "Failure" fi done # Example 2: /usr/local/jamf/bin/jamf policy -event "$event" [ "$?" != "0" ] && echo "Error"
I have been using these techniques for quite a while with no issue, but just recently the policies that check the return code of a policy are reporting failure code 1 even though they appear to complete successfully in every other way. E.g. they show having completed successfully in Jamf Pro, the packages/scripts run by the policies complete without error, etc. I have even tried running some of my policies manually from the command line and checking the return code as in the examples below, and they are all returning 1 now.
jamf policy -event testPolicy; echo $? jamf policy -id 1234; echo $?
I am curious if anyone has run into this or if they have any idea what could be causing this. I know that under the jamf help for the policy verb, there are several different return codes documented, but 1 is not on that list, so I just assume it is a typical failing like you would get from any other similar thing.
I am running something similar in my environment and noticed that I have been running into a similar situation. I noticed that there was an update to Jamf Pro (10.31.1) on the 13th of August 2021 and was wondering if this ties to when you started seeing these errors in your instance.
In addition, have you been able to find a fix for this issue or are you still experiencing this issue?
Same here. I guess this happens because something fails after the policy itself has been (successfully) run, e g in the submitting of logs to jamfcloud.
But there really should be a safe way to catch the error code from the policy.