You need to do a get from the api. There are a lot of posts on here involving using the api. In the script I would 1. Get the serial number from the computer. 2. Do an api get using the /computers/serialnumber/ endpoint. 3. parse that data to create the asset_Tag variable you can then use for the kickstart.
yourjss.com:8443/api is the place to start.
I'm no scripting guru, but is your variable defined properly? don't we need ( ) in the definition?
asset_Tag=$( /usr/bin/awk -F'<asset_tag>|</asset_tag>' '{print $2}'; )
This will get you the asset tag from the JSS and assign it to a variable. Obviously pass your JSS user credentials as the 4th and 5th parameter or you could hard-code it in place of the $4 and $5.
#!/bin/bash
jamfProURL=$(defaults read /Library/Preferences/com.jamfsoftware.jamf.plist jss_url)
apiUser="$4"
apiPass="$5"
serial=$(/usr/sbin/system_profiler SPHardwareDataType 2> /dev/null | grep Serial | awk '{print $NF}')
jamfProId=$(/usr/bin/curl -s -u "${apiUser}:${apiPass}" -H "Accept: application/xml" "${jamfProURL%/}/JSSResource/computers/serialnumber/${serial}/subset/general" | perl -lne 'BEGIN{undef $/} while (/<id>(.*?)</id>/sg){print $1}' | head -1)
asset=$(/usr/bin/curl -s -u "${apiUser}:${apiPass}" -H "Accept: application/xml" "${jamfProURL%/}/JSSResource/computers/id/${jamfProId}/subset/general" | perl -lne 'BEGIN{undef $/} while (/<asset_tag>(.*?)</asset_tag>/sg){print $1}' | head -1)
if [[ -z "$jamfProId" ]] || [[ -z "$asset" ]] || [[ "$asset" =~ (Error|Conflict|Unauthorized|mismatch) ]]; then
echo "There was an error getting the Asset Tag field from the Jamf Pro Server."
exit 1
else
echo "Asset Tag for this machine is $asset"
exit 0
fi
EDITED - If you have a self-signed (untrusted) cert in your JSS, you'll need to modify the curl commands like so:
/usr/bin/curl -s -k -u
Thank you thank you!!!@ryan.ball and @easyedc