# Execute Job DSL script via CasC: jobs: - script: | pipelineJob('jenkins-seed') { blockOn('^.*$') { blockLevel('GLOBAL') scanQueueFor('ALL') } definition { cpsScm { scm { BbS { branches { branchSpec { name('refs/heads/master') } } credentialsId('Build-User') extensions { cleanBeforeCheckout { deleteUntrackedNestedRepositories(true) } localBranch { localBranch('**') } } gitTool(null) id('jenkins-seed') mirrorName('') projectName('JENKINS') repositoryName('jenkins-seed') serverId('Bitbucket') } } } } quietPeriod(10) triggers { hudsonStartupTrigger { label('master') nodeParameterName(null) quietPeriod('10') runOnChoice(null) } } } # Define Bitbucket server in same CasC: unclassified: bitbucketPluginConfiguration: serverList: - adminCredentialsId: API-Token baseUrl: https://redacted.com/ credentialsId: Build-User id: Bitbucket serverName: Bitbucket # Resulting XML is missing remote and browser URLs: false true GLOBAL ALL ^.*$ 10 2 jenkins-seed Build-User refs/heads/master false true ** Bitbucket jenkins-seed Build-User JENKINS JENKINS jenkins-seed jenkins-seed Bitbucket false Jenkinsfile false 10 false # Jenkins logs contain the following lines: 2020-02-24 19:05:16.565+0000 [id=26] INFO c.a.b.j.i.scm.BitbucketSCM#: No Bitbucket Server configuration for serverId Bitbucket 2020-02-24 18:51:16.087+0000 [id=92] INFO c.a.b.j.i.h.HttpRequestExecutorImpl#handleError: Bitbucket - did not accept the request # Job build logs show immediate failure due to missing URLs: 2020-02-24 12:50:10.207 | Started 2020-02-24 12:50:10.220 | Running as runner 2020-02-24 12:50:10.247 | Checking out com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCM into /var/jenkins_home/workspace/jenkins-seed@script to read Jenkinsfile 2020-02-24 12:50:10.311 | using credential Build-User 2020-02-24 12:50:10.349 | > git rev-parse refs/heads/master^{commit} # timeout=10 2020-02-24 12:50:10.388 | ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. 2020-02-24 12:50:10.485 | ERROR: Maximum checkout retry attempts reached, aborting 2020-02-24 12:50:10.485 | Finished: FAILURE # After going to the Configure page for the job and clicking Save without making any changes, XML gets URLs: false true GLOBAL ALL ^.*$ 10 ON_CONNECT 2 jenkins-seed https://redacted.com/scm/jenkins/jenkins-seed.git Build-User refs/heads/master false https://redacted.com/projects/JENKINS/repos/jenkins-seed true ** Bitbucket jenkins-seed Build-User JENKINS Jenkins jenkins-seed jenkins-seed Bitbucket false Jenkinsfile false 10 false