I have a build job that gets initiated by a perforce post submit trigger using an http post request. Something like:
curl --header 'Content-Type: application/json'
--request POST --user $JUSER:$JPASS
--data payload="{change:$CHANGE,p4port:\"$P4PORT\"}"
$JSERVER/p4/change
I also have the same job set to initiate on an automatic schedule process, twice a day
The idea of the perforce trigger compilation is just to make sure that the project is compilling wihtout errors.
The automated one I want it to do an extra step of packaging the project ready for user consumption (this takes signficant time so I don't want it to execut every time)
Things I tried so far
--data payload="{change:$CHANGE,p4port:\"$P4PORT\",P4Triggered:1}"
So I ended up going with pipelines to make this work, that I really suggest people do. Just took one day of research and implementation to have something running in the end. And then I just added a stage with a when step
stage('DEPLOY'){
when {
anyOf{
triggeredBy "TimerTrigger" //deploy if initiated by a timer or manually parameter
expression { params.deploy == true }
}
}
steps{
echo 'Deploying'
bat returnStatus: true, script: '%WORKSPACE%\\TOOLS\\Deploy\\deploy.bat'
}
}
This does the trick. It also has some cool visualization that shows you when something is being bypassed
That being said, I saw this online that might have made it work as well with a frestyle project and a perforce trigger
--data 'json={"parameter":[{"name":"PARAMNAME","value":"agent-name"}]}&Submit=Build'
I might try it later.