aws-deployment-framework icon indicating copy to clipboard operation
aws-deployment-framework copied to clipboard

Configured build step for Jenkins gives "Invalid provider Jenkins" error.

Open eriklz opened this issue 5 years ago • 3 comments

Recently we got a requirement to integrate with Jenkins as a build server for some pipelines, which we need to "lift and shift" into AWS and for the time being run them as-is, using Jenkins.

I have configured the Jenkins server with the plugin for AWS Codepipeline as the Codepipeline documentation specifies and a project inside Jenkins to be executed. Next I created a test pipeline for ADF with a build step configured to use the Jenkins server:

      build:
        provider: jenkins
        properties:
          project_name: Test1
          server_url: "https://nnn.nnn.nnn.nnn/"
          provider_name: Jenkins

The aws-deployment-framework-pipelines pipeline failed though with an "Invalid provider Jenkins" error. Looking at the stack trace the error happened in the adf_codepipeline.py construct, in this function below. It looks like there is no Jenkins option here at all. In this casee, should not Jenkins be treated the same as "Manual" and not get assigned a role, since the work will be passed to Jenkins server and not any execution in an AWS account directly?

    def _generate_codepipeline_access_role(self): #pylint: disable=R0911
        if self.provider == "CodeCommit":
            return "arn:aws:iam::{0}:role/adf-codecommit-role".format(self.map_params['default_providers']['source']['properties']['account_id'])
        if self.provider == "GitHub":
            return None
        if self.provider == "CodeBuild":
            return None
        if self.provider == "S3" and self.category == "Source":
            # This could be changed to use a new role that is bootstrapped, ideally we rename adf-cloudformation-role to a generic deployment role name
            return "arn:aws:iam::{0}:role/adf-codecommit-role".format(self.map_params['default_providers']['source']['properties']['account_id'])
        if self.provider == "S3" and self.category == "Deploy":
            # This could be changed to use a new role that is bootstrapped, ideally we rename adf-cloudformation-role to a generic deployment role name
            return "arn:aws:iam::{0}:role/adf-cloudformation-role".format(self.target['id'])
        if self.provider == "ServiceCatalog":
            # This could be changed to use a new role that is bootstrapped, ideally we rename adf-cloudformation-role to a generic deployment role name
            return "arn:aws:iam::{0}:role/adf-cloudformation-role".format(self.target['id'])
        if self.provider == "CodeDeploy":
            # This could be changed to use a new role that is bootstrapped, ideally we rename adf-cloudformation-role to a generic deployment role name
            return "arn:aws:iam::{0}:role/adf-cloudformation-role".format(self.target['id'])
        if self.provider == "Lambda":
            # This could be changed to use a new role that is bootstrapped, ideally we rename adf-cloudformation-role to a generic deployment role name
            return None
        if self.provider == "CloudFormation":
            return "arn:aws:iam::{0}:role/adf-cloudformation-role".format(self.target['id'])
        if self.provider == "Manual":
            return None
        raise Exception('Invalid Provider {0}'.format(self.provider))

eriklz avatar Feb 06 '20 15:02 eriklz

A few notes here after some additional testing and changes that allowed me to get a build step with Jenkins/Cloudbees working in some fashion:

  • Updating _generate_codepipeline_access_role() to return None for Jenkins provider
  • Changing the ActionTypeId settings so that its Owner field is set to "Custom" instead of "AWS", which ADF currently sets it to. This is what the Jenkins plugin for AWS CodePipeline expects.
  • Changing the Configuration section of the same action to only include the ProjectName field and not the ServerURL and ProviderName fields. The latter two are needed when registering the custom action, but not once the custom action is in place - then it will just trigger an error.

Will do further testing to see if other issues pop up.

eriklz avatar Feb 10 '20 17:02 eriklz

Hi @eriklz

Thanks a bunch for diving into this, very cool to see Jenkins being used as part of ADF. If you would have the time to bundle up your changes into a Pull Request that would be very helpful. Otherwise I will take your notes and attempt to get this working in my own environment when time permits.

bundyfx avatar Feb 11 '20 10:02 bundyfx

Ill add this into the 3.0.5 milestone as I would love to see this working as intended for other Jenkins users.

bundyfx avatar Feb 17 '20 10:02 bundyfx

I'm closing this issue as it has been inactive for a long time. This probably means that it is not reproducible or it has been fixed in the meanwhile.

Please reopen if you still encounter this issue with the latest stable version.

Thank you!

sbkok avatar May 17 '24 19:05 sbkok