pycontribs / jenkinsapi

A Python API for accessing resources and configuring Hudson & Jenkins continuous-integration servers
http://pypi.python.org/pypi/jenkinsapi
MIT License
859 stars 485 forks source link

Get scm fails when job is configured with plugin workflow-job@2.17 #624

Closed marcellodesales closed 5 years ago

marcellodesales commented 6 years ago
ISSUE TYPE

-Bug Report

Jenkinsapi VERSION

latest

Jenkins VERSION

2.107.1

SUMMARY

When using Flows, Pipelines, the SCM settings (type, URL, etc) can't be fetched

EXPECTED RESULTS

Should be able to fetch

ACTUAL RESULTS

Exception is thrown when trying to get any configuration such as scm

USEFUL INFORMATION
<?xml version='1.1' encoding='UTF-8'?>
<flow-definition plugin="workflow-job@2.17">
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.29.0">
      <projectUrl>https://github.company.com/mdesales/demo/</projectUrl>
      <displayName></displayName>
    </com.coravy.hudson.plugins.github.GithubProjectProperty>
    <com.tikal.hudson.plugins.notification.HudsonNotificationProperty plugin="notification@1.12">
      <endpoints>
        <com.tikal.hudson.plugins.notification.Endpoint>
          <protocol>HTTP</protocol>
          <format>JSON</format>
          <urlInfo>
            <urlOrId>http://abc258888888888888888a3a6bfc1-698684238.us-west-1.elb.amazonaws.com</urlOrId>
            <urlType>PUBLIC</urlType>
          </urlInfo>
          <event>all</event>
          <timeout>3000</timeout>
          <loglines>0</loglines>
          <retries>0</retries>
        </com.tikal.hudson.plugins.notification.Endpoint>
      </endpoints>
    </com.tikal.hudson.plugins.notification.HudsonNotificationProperty>
    <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
      <triggers/>
    </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
  </properties>
  <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.45">
    <scm class="hudson.plugins.git.GitSCM" plugin="git@3.8.0">
      <configVersion>2</configVersion>
      <userRemoteConfigs>
        <hudson.plugins.git.UserRemoteConfig>
          <url>https://github.company.com/mdesales/demo/</url>
          <credentialsId>4fedc681-251a-41a4-8c9e-233ea827a5ea</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>
    <scriptPath>Jenkinsfile</scriptPath>
    <lightweight>true</lightweight>
  </definition>
  <triggers/>
  <authToken>1a2b3c4d5e</authToken>
  <disabled>false</disabled>
</flow-definition>
Traceback (most recent call last):
  File "src/controller/jenkins.py", line 127, in <module>
    print_job_details(job)
  File "src/controller/jenkins.py", line 21, in print_job_details
    print("Get SCM Url: {}".format(job.get_scm_url()))
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jenkinsapi/job.py", line 499, in get_scm_url
    scm = self.get_scm_type()
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jenkinsapi/job.py", line 481, in get_scm_type
    scm_class = element_tree.find('scm').get('class')
AttributeError: 'NoneType' object has no attribute 'get'
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

Closed due to inactivity