1
votes

I have a seed job creating Jenkins jobs and while the jobs are created, they're missing things like SCM, labels, and wrappers.

Here's a simple job script that gets created:

job(jobName) {
  label('pdfs')
  description jobDesc
  parameters {
    textParam('PDF_BRANCH', 'release/server_2.11.1', '')
  }
  scm {
    git {
      remote {
        url('https://stash.domain.com/scm/project/repo.git')
        credentials('repo-user-creds')
      }
      branch('*/master')
    }
  }
  triggers {
    scm 'H/5 * * * *'
  }
  steps {
    shell jobScript
  }
  wrappers {
    rbenv('1.9.3-p484') {
      ignoreLocalVersion()
      gems('bundler', 'rake')
    }
  }
}

But the resulting job has no SCM or label: enter image description here The XML on the server seems to include SCM and label:

<?xml version="1.0" encoding="UTF-8"?><project>
    <actions/>
    <description>Testing pdf creation job against Elemental Server</description>
    <keepDependencies>false</keepDependencies>
    <properties>
        <hudson.model.ParametersDefinitionProperty>
            <parameterDefinitions>
                <hudson.model.TextParameterDefinition>
                    <name>PDF_BRANCH</name>
                    <defaultValue>release/server_2.11.1</defaultValue>
                    <description/>
                </hudson.model.TextParameterDefinition>
            </parameterDefinitions>
        </hudson.model.ParametersDefinitionProperty>
    </properties>
    <canRoam>false</canRoam>
    <disabled>false</disabled>
    <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
    <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
    <triggers>
        <hudson.triggers.SCMTrigger>
            <spec>H/5 * * * *</spec>
            <ignorePostCommitHooks>false</ignorePostCommitHooks>
        </hudson.triggers.SCMTrigger>
    </triggers>
    <concurrentBuild>false</concurrentBuild>
    <builders>
        <hudson.tasks.Shell>
            <command>
# REMOVED FOR BREVITY
</command>
        </hudson.tasks.Shell>
    </builders>
    <publishers/>
    <buildWrappers>
        <ruby-proxy-object>
            <ruby-object ruby-class="Jenkins::Tasks::BuildWrapperProxy" pluginid="rbenv">
                <pluginid ruby-class="String" pluginid="rbenv">rbenv</pluginid>
                <object ruby-class="RbenvWrapper" pluginid="rbenv">
                    <version ruby-class="String" pluginid="rbenv">1.9.3-p484</version>
                    <ignore__local__version ruby-class="String" pluginid="rbenv">true</ignore__local__version>
                    <gem__list ruby-class="String" pluginid="rbenv">bundler,rake</gem__list>
                    <rbenv__root ruby-class="String" pluginid="rbenv">$HOME/.rbenv</rbenv__root>
                    <rbenv__repository ruby-class="String" pluginid="rbenv">https://github.com/sstephenson/rbenv.git</rbenv__repository>
                    <rbenv__revision ruby-class="String" pluginid="rbenv">master</rbenv__revision>
                    <ruby__build__repository ruby-class="String" pluginid="rbenv">https://github.com/sstephenson/ruby-build.git</ruby__build__repository>
                    <ruby__build__revision ruby-class="String" pluginid="rbenv">master</ruby__build__revision>
                </object>
            </ruby-object>
        </ruby-proxy-object>
    </buildWrappers>
    <assignedNode>pdfs</assignedNode>
    <scm class="hudson.plugins.git.GitSCM">
        <userRemoteConfigs>
            <hudson.plugins.git.UserRemoteConfig>
                <url>https://stash.domain.com/scm/project/repo.git</url>
                <credentialsId>repo-user-creds</credentialsId>
            </hudson.plugins.git.UserRemoteConfig>
        </userRemoteConfigs>
        <branches>
            <hudson.plugins.git.BranchSpec>
                <name>*/master</name>
            </hudson.plugins.git.BranchSpec>
        </branches>
        <configVersion>2</configVersion>
        <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
        <gitTool>Default</gitTool>
    </scm>

I'm very new to Jenkins job-dsl so I'm sure I'm missing something fairly obvious but I just don't know what it is. Any help is very much appreciated, thanks!

2
so do you have the git plugin installed? - KeepCalmAndCarryOn
Yes, I can manually add an SCM source, select credentials, etc, and it'll work. - Resisty

2 Answers

0
votes
0
votes

Try validating your code here job DSL playground

If all the tags are coming fine then u might have to check the DSL plugin version and any updates to the DSL methods