This problem is happening to me as well.
I have a working jenkins job, which gets code from git and execute sonar-scanner in the downloaded code.
I got the config.xml from the working job and I created a new job using the same config.xml, but just changing the it's name.
The new Job is created with sucess, however the build step to run sonar is not there, but if I look in the new job config.xml it is correct, if I ran the job, the sonar part does't ran.
I did a test with another build step only to run a command line (ls -la) and creating a new job works fine, so perhaps it is something related to the sonar plugin ????
This is my config.xml:
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.4.4">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>https://github.com/SonarSource/sonar-examples.git</url>
<credentialsId>REMOVED</credentialsId>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions/>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.plugins.sonar.SonarRunnerBuilder plugin="sonar@2.4">
<project></project>
<properties>sonar.projectKey=org.sonarqube:javascript-simple-sq-scanner
sonar.projectName=JavaScript :: Simple Project :: SonarQube Scanner
sonar.projectBaseDir=./projects/languages/javascript/javascript-sonar-runner
sonar.projectVersion=1.0
sonar.sources=src
sonar.language=js</properties>
<javaOpts></javaOpts>
<additionalArguments>-X</additionalArguments>
<jdk>(Inherit From Job)</jdk>
<task></task>
</hudson.plugins.sonar.SonarRunnerBuilder>
</builders>
<publishers/>
<buildWrappers/>
</project>
this is command to create a job using webapi:
curl -s --data-binary @config.xml -H "Content-Type: application/xml" -X POST http://localhost:8080/createItem?name=NEWITEM
In config.xml of a Maven job, I see "goals" but not "defaultGoal".
Are you sure that this a defect?
And is this still a problem for you?