简体   繁体   中英

Is it possible to trigger a multibranch pipeline jenkins build remotely?

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]

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM