-
Bug
-
Resolution: Not A Defect
-
Major
-
None
-
Jenkins 2.263.4 LTS
atlassian-bitbucket-server-integration plugin: 2.1.2
I've created a simple free style job with this configuration (no HTTP credentials, just SSH)
As you can see, the connection has tested successfully.
The job itself just runs a simple `echo "Hello World!"`
Job fails with the following error message:
FATAL: Git repository URL 1 is an empty string in job definition. Checkout requires a valid repository URL java.lang.IllegalArgumentException: Git repository URL 1 is an empty string in job definition. Checkout requires a valid repository URL at hudson.plugins.git.GitSCM.buildEnvironment(GitSCM.java:1537) at com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCM.buildEnvironment(BitbucketSCM.java:183) at hudson.scm.SCM.buildEnvVars(SCM.java:554) at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:951) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1290) at com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCM.checkout(BitbucketSCM.java:206) at hudson.scm.SCM.checkout(SCM.java:505) at hudson.model.AbstractProject.checkout(AbstractProject.java:1206) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509) at hudson.model.Run.execute(Run.java:1907) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Finished: FAILURE
Looking at config.xml
<scm class="com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCM" plugin="atlassian-bitbucket-server-integration@2.1.2"> <gitSCM plugin="git@4.5.2"> <configVersion>2</configVersion> <userRemoteConfigs class="singleton-list"> <hudson.plugins.git.UserRemoteConfig> <name>reducted-repo</name> <credentialsId>reducted-ssh-creds</credentialsId> </hudson.plugins.git.UserRemoteConfig> </userRemoteConfigs> <branches> <hudson.plugins.git.BranchSpec> <name>refs/heads/master</name> </hudson.plugins.git.BranchSpec> </branches> <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> <browser class="hudson.plugins.git.browser.Stash"> <url></url> </browser> <submoduleCfg class="empty-list"/> <extensions/> </gitSCM> <branches reference="../gitSCM/branches"/> <extensions/> <id>d46fa536-aaa0-4a5e-93fe-01ece39a4f52</id> <repositories> <com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository> <credentialsId></credentialsId> <sshCredentialsId>reducted-ssh-creds</sshCredentialsId> <projectKey>reducted-project</projectKey> <projectName>reducted-project</projectName> <repositoryName>reducted-repo</repositoryName> <repositorySlug>reducted-repo</repositorySlug> <serverId>reducted-server-id</serverId> <mirrorName></mirrorName> </com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository> </repositories> <isWebhookRegistered>false</isWebhookRegistered> </scm>
If you look at the `hudson.plugins.git.UserRemoteConfig` element you will see that the `<url>` element is missing.
Creating the same job through Job DSL plugin and fixing missing `<url>` element makes job execution successful.
Bellow is a snippet of the Job DSL script with the fixup (configure block at the end) to make this configuration workable.
job(JOB_NAME) { scm { BbS { id( BITBUCKET_SERVER_ID ) serverId( BITBUCKET_SERVER_ID ) branches { branchSpec { name( 'refs/heads/' + BRANCH ) } } credentialsId( '' ) gitTool( 'Default' ) mirrorName( '' ) projectName( PROJECT_NAME ) repositoryName( REPO_NAME ) sshCredentialsId( SSH_CREDENTIALS_ID ) } } ... // Little fixup for missing remote on gitSCM configure { rootNode -> rootNode / scm / gitSCM / userRemoteConfigs / 'hudson.plugins.git.UserRemoteConfig' / url << String.format( 'ssh://git@%s/%s/%s.git', BITBUCKET_SERVER_FQDN, PROJECT_NAME, REPO_NAME ) } }
Even though I can create my jobs through Job DSL, I cannot edit them after the fact, because making any changes to the job (i.e. changing branch name to a feature branch) results in SSH url being removed from the 'hudson.plugins.git.UserRemoteConfig'
- is duplicated by
-
JENKINS-64867 atlassian bitbucket plugin is broken with SSH only credentials for multibranch jobs.
- Closed