Managing integration of CI/CD server to DevOps Environment
Tags: devops, pipelines, cicd, integrations
Published: 2020-03-20 09:04:44

We all know that CI or CD server needs to be tightly connected or integrated across your DevOps environment.

But the problem in most of the CI servers today, is that you have to configure for each job every time.
For example, if you are trying to deploy to Kubernetes using Jenkins, you have to configure this at a Job level and you can only verify this by actually running the build.
If you need this KubeConfig in few other jobs the only way in here is that you add the same config file in all other required jobs.
Now imagine, you need to change something in the config file, now you have to go to all other places and change them, which is `not effective`.
This stands the same for deploying to Google Cloud or AWS or any other cloud provider which might also require some plugin to make it work.

So just to tackle this problem, [JFrog Pipelines](https://jfrog.com/pipelines/) extracted these out into a central system, created a pointer for you which you can use it in your steps where our platform gonna inject them during run time and we call these as Integrations.

**Integrations** are used to connect your Pipelines CI or CD workflows to third party platforms or services and manage secrets like keys, tokens, passwords that are needed for Steps in a Pipeline to interact with the source. 
All credential information is encrypted and maintained separately from the pipeline definition, and held in a secure storage.

The biggest advantages of our design for integrations are:

1. Integrations are created in the UI and used with friendly names in your YAML config. This means you do not have to touch your automation scripts when an integration is updated.
2. Integrations are securely stored in a `Vault store` and encrypted at rest and in-flight.
3. Integrations values are not revealed in logs unless you choose to print them out as part of your workflow.
You can scope each integration to allow or deny access for Pipeline Sources

Let me show an example of adding an integration and using it in one of your step.

#### Add New Integration 
To add new integration, Go to Pipelines->Integrations tab and click on `Add an Integration`,
You can give some friendly name and select the type of integration which you want to create.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/e72nkhmattv8h2seah26.png)

The available integration types for Jfrog Pipelines are: 
[Airbrake](https://www.jfrog.com/confluence/display/CICD/Airbrake+Integration), [ Artifactory](https://www.jfrog.com/confluence/display/CICD/Artifactory+Integration), [ AWS Keys](https://www.jfrog.com/confluence/display/CICD/AWS+Keys+Integration), [ Azure Keys](https://www.jfrog.com/confluence/display/CICD/Azure+Keys+Integration), [ Bitbucket](https://www.jfrog.com/confluence/display/CICD/Bitbucket+Integration), [ Digital Ocean](https://www.jfrog.com/confluence/display/CICD/Digital+Ocean+Integration), [ Distribution](https://www.jfrog.com/confluence/display/CICD/Distribution+Integration), [ Docker Registry](https://www.jfrog.com/confluence/display/CICD/Docker+Registry+Integration), [ External Webhook](https://www.jfrog.com/confluence/display/CICD/External+Webhook+Integration), [ File Server](https://www.jfrog.com/confluence/display/CICD/File+Server+Integration), [ Generic](https://www.jfrog.com/confluence/display/CICD/Generic+Integration), [ Github Enterprise ](https://www.jfrog.com/confluence/display/CICD/GitHub+Enterprise+Integration), [ Github](https://www.jfrog.com/confluence/display/CICD/GitHub+Integration), [ Gitlab](https://www.jfrog.com/confluence/display/CICD/GitLab+Integration), [ Google Cloud](https://www.jfrog.com/confluence/display/CICD/Google+Cloud+Integration), [ Internal Webhook Integration](https://www.jfrog.com/confluence/display/CICD/Internal+Webhook+Integration), [ Jira](https://www.jfrog.com/confluence/display/CICD/Jira+Integration), [ Kubernetes](https://www.jfrog.com/confluence/display/CICD/Kubernetes+Integration), [ Newrelic](https://www.jfrog.com/confluence/display/CICD/NewRelic+Integration), [ PEM Key](https://www.jfrog.com/confluence/display/CICD/PEM+Key+Integration), [ Slack](https://www.jfrog.com/confluence/display/CICD/Slack+Integration), [ SMTP Credentials](https://www.jfrog.com/confluence/display/CICD/SMTP+Credentials+Integration), [ SSH Key](https://www.jfrog.com/confluence/display/CICD/SSH+Key+Integration)

Once you added all the required fields:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ze165fo9mavj4i1crzvs.png)

You can also set which Pipeline sources can use this integration:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f0ml01o8udg4b8ods4oz.png)

After creating, you can add the integration directly to a step:
```yaml
   steps:          
      - name: sample_bash
        type: Bash
        configuration:
          integrations:
            - name: myArtifactory
        execution:
          onExecute:
            - echo "executing bash step."
            - echo $int_myArtifactory_url
```
when you do that, a set of environment variables is automatically made available.

You can also send notifications using utility function: [send_notification](https://www.jfrog.com/confluence/display/CICD/Utility+Functions#UtilityFunctions-send_notification) whenever your step succeeds or fails due to some reason using Notification integrations: Airbrake, Slack, Jira, NewRelic, Outgoing webhook, SmtpCreds(email)
```yaml
   steps:
      - name: sample_bash
        type: Bash
        configuration:
          integrations:
            - name: myArtifactory
            - name: mySlack
            - name: myJira
        execution:
          onExecute: 
            - echo "executing bash step."
          onSuccess:
            - send_notification mySlack
          onFailure:
            - send_notification myJira --project-id myProjectOnJira --type Bug --summary "sample_bash step: ${step_id} failed"
```
Hope this helps! :)