awslabs / aws-codepipeline-plugin-for-jenkins

Use this plugin to integrate your Jenkins project with a pipeline in AWS CodePipeline. For more information and step-by-step directions on how to install and configure this plugin, follow the Four Stage Pipeline Tutorial. http://docs.aws.amazon.com/codepipeline/latest/userguide/getting-started-4.html
Apache License 2.0
82 stars 68 forks source link

NullPointerException on PutJobSuccessResult for builds with artifacts (version 0.29) #27

Closed richardowen closed 7 years ago

richardowen commented 7 years ago

This issue appears to be new in version 0.29. I'm getting these errors at the end of my builds now:

[AWS CodePipeline Plugin] Publishing artifacts
[AWS CodePipeline Plugin] Build succeeded, calling PutJobSuccessResult
ERROR: Build step failed with exception
java.lang.NullPointerException
    at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
    at java.util.regex.Matcher.reset(Matcher.java:309)
    at java.util.regex.Matcher.<init>(Matcher.java:229)
    at java.util.regex.Pattern.matcher(Pattern.java:1093)
    at java.util.Formatter.parse(Formatter.java:2547)
    at java.util.Formatter.format(Formatter.java:2501)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2940)
    at com.amazonaws.codepipeline.jenkinsplugin.LoggingHelper.log(LoggingHelper.java:28)
    at com.amazonaws.codepipeline.jenkinsplugin.AWSCodePipelinePublisher.perform(AWSCodePipelinePublisher.java:170)
    at hudson.tasks.BuildStepMonitor$2.perform(BuildStepMonitor.java:32)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:621)
    at hudson.model.Run.execute(Run.java:1760)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:405)
Build step 'AWS CodePipeline Publisher' marked build as failure
Finished: FAILURE

Sometimes there is no stack trace:

[AWS CodePipeline Plugin] Publishing artifacts
[AWS CodePipeline Plugin] Build succeeded, calling PutJobSuccessResult
ERROR: Build step failed with exception
java.lang.NullPointerException
Build step 'AWS CodePipeline Publisher' marked build as failure
Finished: FAILURE

These builds all have a single artifact with a blank location (to zip up the whole workspace). Our build which doesn't have any artifacts is succeeding.

The PutJobSuccessResult call appears to have been successful because CodePipeline thinks the job has succeeded. The Jenkins job is marked as failed however.

maggiecopyAWS commented 7 years ago

I could not reproduce the issue. Would you mind posting more details about your environment?

richardowen commented 7 years ago

This appears to be an issue with upgrading from 0.28 to 0.29. If you create a fresh job on 0.29 it will work fine. If you create a job on 0.28 and then upgrade the plugin to 0.29 it will fail. It will succeed again after you save the job configuration on 0.29 (without making any changes).

I did the following test:

  1. Create a test job on 0.28 and run the pipeline (succeeds)
  2. Upgrade plugin to 0.29
  3. Run the pipeline again (fails)
  4. Go to the job configuration and click save
  5. Run the pipeline again (succeeds)

I took a snapshot of the job directory before and after step 4. Before saving, this was the job config.xml:

<?xml version='1.0' encoding='UTF-8'?>
<project>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties/>
  <scm class="com.amazonaws.codepipeline.jenkinsplugin.AWSCodePipelineSCM" plugin="aws-codepipeline@0.28">
    <clearWorkspace>true</clearWorkspace>
    <projectName>CodePipeline_Test_2</projectName>
    <actionTypeCategory>Build</actionTypeCategory>
    <actionTypeProvider>Jenkins</actionTypeProvider>
    <actionTypeVersion>4</actionTypeVersion>
    <region>eu-west-1</region>
    <awsAccessKey></awsAccessKey>
    <awsSecretKey></awsSecretKey>
    <proxyHost></proxyHost>
    <proxyPort>0</proxyPort>
    <awsClientFactory/>
  </scm>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers>
    <hudson.triggers.SCMTrigger>
      <spec>* * * * *</spec>
      <ignorePostCommitHooks>false</ignorePostCommitHooks>
    </hudson.triggers.SCMTrigger>
  </triggers>
  <concurrentBuild>false</concurrentBuild>
  <builders/>
  <publishers>
    <com.amazonaws.codepipeline.jenkinsplugin.AWSCodePipelinePublisher plugin="aws-codepipeline@0.28">
      <outputArtifacts>
        <com.amazonaws.codepipeline.jenkinsplugin.OutputArtifact>
          <location></location>
        </com.amazonaws.codepipeline.jenkinsplugin.OutputArtifact>
      </outputArtifacts>
      <awsClientFactory/>
    </com.amazonaws.codepipeline.jenkinsplugin.AWSCodePipelinePublisher>
  </publishers>
  <buildWrappers/>
</project>

After saving, this was the new job xml:

<?xml version='1.0' encoding='UTF-8'?>
<project>
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties/>
  <scm class="com.amazonaws.codepipeline.jenkinsplugin.AWSCodePipelineSCM" plugin="aws-codepipeline@0.29">
    <clearWorkspace>true</clearWorkspace>
    <projectName>CodePipeline_Test_2</projectName>
    <actionTypeCategory>Build</actionTypeCategory>
    <actionTypeProvider>Jenkins</actionTypeProvider>
    <actionTypeVersion>4</actionTypeVersion>
    <region>eu-west-1</region>
    <awsAccessKey></awsAccessKey>
    <awsSecretKey></awsSecretKey>
    <proxyHost></proxyHost>
    <proxyPort>0</proxyPort>
    <awsClientFactory/>
  </scm>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers>
    <hudson.triggers.SCMTrigger>
      <spec>* * * * *</spec>
      <ignorePostCommitHooks>false</ignorePostCommitHooks>
    </hudson.triggers.SCMTrigger>
  </triggers>
  <concurrentBuild>false</concurrentBuild>
  <builders/>
  <publishers>
    <com.amazonaws.codepipeline.jenkinsplugin.AWSCodePipelinePublisher plugin="aws-codepipeline@0.29">
      <outputArtifacts>
        <com.amazonaws.codepipeline.jenkinsplugin.OutputArtifact>
          <location></location>
          <artifactName></artifactName>
        </com.amazonaws.codepipeline.jenkinsplugin.OutputArtifact>
      </outputArtifacts>
      <awsClientFactory/>
    </com.amazonaws.codepipeline.jenkinsplugin.AWSCodePipelinePublisher>
  </publishers>
  <buildWrappers/>
</project>

I think the relevant difference is probably that after saving the outputArtifact has an (empty) artifactName.

maggiecopyAWS commented 7 years ago

Thank you for bringing this issue to us. We have been able to reproduce this issue, and new release aws-codepipeline-0.32 fixes the problem.

richardowen commented 7 years ago

Thanks. I can confirm this issue is fixed with version 0.32.