1

It seems only freestyle has that option. This appears to be outdated.

Jenkinsfiles do not appear to be able to read a remote trigger:

WorkflowScript: 8: Invalid trigger type "RemoteBuildTrigger". Valid trigger types: [upstream, cron, githubPush, pollSCM]

compsciman
  • 349
  • 3
  • 17
  • Share the content in your Jenkins file. – ycr Dec 07 '22 at 00:45
  • @ycr regardless of what I put in the trigger {} section it won't register unless it's one of upstream, cron, githubPush or pollSCM - none of which are remote triggers. So basically I'm seeing if there's another way. – compsciman Dec 07 '22 at 00:58

1 Answers1

2

Do not put anything in the triggers section. Have a Jenkinsfile like below.

pipeline {
    agent any
    stages {
        stage('Hello6') {
            steps {
                script {
                    script {
                        echo "Somethingggg"
                    }
                   
                }
            }
        }
   }
}

Then generate the token and then trigger the build. Following commands require curl and jq

# Change the following appropriately
JENKINS_URL="http://localhost:8080"
JENKINS_USER=admin
JENKINS_USER_PASS=admin

JENKINS_CRUMB=$(curl -u "$JENKINS_USER:$JENKINS_USER_PASS" -s --cookie-jar /tmp/cookies $JENKINS_URL'/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')

#Get the Access token**
ACCESS_TOKEN=$(curl -u "$JENKINS_USER:$JENKINS_USER_PASS" -H $JENKINS_CRUMB -s \
                    --cookie /tmp/cookies $JENKINS_URL'/me/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken' \
                    --data 'newTokenName=GlobalToken' | jq -r '.data.tokenValue')

# You can get the correct URL by navigating to the branch build from the Jenkins console.
curl -X POST -u $JENKINS_USER:$ACCESS_TOKEN -H $JENKINS_CRUMB "$JENKINS_URL/job/$FOLDER_NAME/job/$MULTIBRANCH_JOB_NAME/job/$BRANCH_NAME/build"
ycr
  • 12,828
  • 2
  • 25
  • 45
  • Thanks @ycr - using that `$JENKINS_CRUMB` curl results in an `Error 401 Unauthorized`. I have tried with an api token with my admin user as well as my admin password. The solution I see would be to add the api token into my multibranch pipeline but as the option is greyed out in multibranch pipelines I don't see a way to get past that authorization issue? – compsciman Dec 07 '22 at 01:54
  • @compsciman initial steps are not related to Multibranch pipeline. You should be able to generate an Access Token to access Jenkins APIs etc. – ycr Dec 07 '22 at 02:07
  • 1
    Working now after figuring out how to go through authentication in my org. Thanks! – compsciman Dec 07 '22 at 03:52