jenkinsci / pipeline-aws-plugin

Jenkins Pipeline Step Plugin for AWS
https://plugins.jenkins.io/pipeline-aws/
Apache License 2.0
431 stars 203 forks source link

Getting InvalidFileExistsBehaviorException even though fileExistsBehavior is not specified #332

Open waseemahammed opened 1 month ago

waseemahammed commented 1 month ago

Jenkins and plugins versions report

Getting InvalidFileExistsBehaviorException even though fileExistsBehavior is not specified.

Running the following block on Jenkins pipeline:

        createDeployment(
            applicationName: "${APPLICATION_NAME}",
            deploymentGroupName: "${DEPLOYMENT_GROUP}",
            deploymentConfigName: 'CodeDeployDefault.AllAtOnce',
            description: '${SERVICE_NAME} deployment',
            waitForCompletion: 'true',
            s3Bucket: "${S3_BUCKET}",
            s3Key: "${SERVICE_NAME}/dev/appspec.json",
            s3BundleType: 'JSON'
        )

Getting following error:

com.amazonaws.services.codedeploy.model.InvalidFileExistsBehaviorException: For Lambda, ECS and Kubernetes deployment, fileExistsBehavior can not be specified (Service: AmazonCodeDeploy; Status Code: 400; Error Code: InvalidFileExistsBehaviorException; Request ID: 31fec058-f220-4842-bb9c-bdef9ef4734c; Proxy: null)

What Operating System are you using (both controller, and any agents involved in the problem)?

Running this on jenkins node

Reproduction steps

  1. Install pipeline-aws plugin on Jenkins
  2. Create an Application, Deployment group in AWS Code Deploy.
  3. Create a jenkins pipeline and furnish the details like below.
  4. Run Jenkins pipeline.
  createDeployment(
      applicationName: "${APPLICATION_NAME}",
      deploymentGroupName: "${DEPLOYMENT_GROUP}",
      deploymentConfigName: 'CodeDeployDefault.AllAtOnce',
      description: '${SERVICE_NAME} deployment',
      waitForCompletion: 'true',
      s3Bucket: "${S3_BUCKET}",
      s3Key: "${SERVICE_NAME}/dev/appspec.json",
      s3BundleType: 'JSON'
  )

Expected Results

Code Deploy deployment should be created with appspec provided in reproduction steps.

Actual Results

Jenkins console output:

com.amazonaws.services.codedeploy.model.InvalidFileExistsBehaviorException: For Lambda, ECS and Kubernetes deployment, fileExistsBehavior can not be specified (Service: AmazonCodeDeploy; Status Code: 400; Error Code: InvalidFileExistsBehaviorException; Request ID: 31fec058-f220-4842-bb9c-bdef9ef4734c; Proxy: null)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1912)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1450)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1419)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1183)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:838)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:805)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:779)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:735)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:717)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:581)
    at PluginClassLoader for aws-java-sdk-minimal//com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:559)
    at PluginClassLoader for aws-java-sdk-codedeploy//com.amazonaws.services.codedeploy.AmazonCodeDeployClient.doInvoke(AmazonCodeDeployClient.java:4389)
    at PluginClassLoader for aws-java-sdk-codedeploy//com.amazonaws.services.codedeploy.AmazonCodeDeployClient.invoke(AmazonCodeDeployClient.java:4356)
    at PluginClassLoader for aws-java-sdk-codedeploy//com.amazonaws.services.codedeploy.AmazonCodeDeployClient.invoke(AmazonCodeDeployClient.java:4345)
    at PluginClassLoader for aws-java-sdk-codedeploy//com.amazonaws.services.codedeploy.AmazonCodeDeployClient.executeCreateDeployment(AmazonCodeDeployClient.java:1609)
    at PluginClassLoader for aws-java-sdk-codedeploy//com.amazonaws.services.codedeploy.AmazonCodeDeployClient.createDeployment(AmazonCodeDeployClient.java:1578)
    at PluginClassLoader for pipeline-aws//de.taimos.pipeline.aws.code.deploy.CreateDeployStep$Execution.run(CreateDeployStep.java:166)
    at PluginClassLoader for pipeline-aws//de.taimos.pipeline.aws.code.deploy.CreateDeployStep$Execution.run(CreateDeployStep.java:141)
    at PluginClassLoader for workflow-step-api//org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
Finished: FAILURE

Anything else?

No response

Are you interested in contributing a fix?

I would be happy to.

We have a check here which can extensively check which platform we are deploying on. https://github.com/jenkinsci/pipeline-aws-plugin/blob/ab51af4abbb17a476796804ab6eb9f54aff1ebb6/src/main/java/de/taimos/pipeline/aws/code/deploy/CreateDeployStep.java#L178

By default the code has set 'fileExistsBehavior' to 'DISALLOW' which need to be checked based on the platform of deployment and not AWS default value here.

waseemahammed commented 1 month ago

I have raised a PR for the change : https://github.com/jenkinsci/pipeline-aws-plugin/pull/333