开发者

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

It seems only freestyle has that option. This appears to be outdat开发者_高级运维ed.

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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜