CI/CD

DevDynamics tracks builds using post-build metadata provided through the specified curl request.

Firewall Configuration

To enable CI/CD tools(Jenkins) connection to DevDynamics, permit outbound traffic for:

  • IP Address: 3.131.112.244

Prerequisites

API Details

  • Endpoint: https://api.devdynamics.ai/api/v1/deployment/{your-devdynamics-orgId}/notify

  • Method: POST

  • Important Note: Request must be called in the POST-BUILD STEP of your Jenkins pipeline

Payload Fields Explanation

  • id: Execution Id (mandatory)

  • name: Name of the pipeline/job (mandatory)

  • pipelineId: Pipeline/Job (if you don't have id , send name) (mandatory)

  • timeStamp: Timestamp of the event (mandatory)

  • startedAt: Start Timestamp when the build started (mandatory)

  • completedAt: End Timestamp when the build completed (mandatory)

  • htmlUrl: URL to the build or deployment details

  • source: Source of the deployment (example "Jenkins")

  • status: Deployment status (e.g., "success", "failed") (mandatory)

  • repository: Name of the repository (mandatory)

  • artifact: Version or identifier of the deployed artifact

  • environment: Deployment environment (e.g., "production") (mandatory in case of cd event)

  • commit: Latest commit hash (mandatory)

  • additionalInfo: Optional additional metadata (e.g., a tag)

  • stages: Array of deployment stages with their details

  • tags: (Optional)

Headers

Samples

Note: The request must be called in the POST-BUILD STEP of your Jenkins pipeline to track deployment events accurately.

curl --location \
 --request \
 POST 'https://api.devdynamics.ai/api/v1/deployment/<your-devdynamics-orgId>/notify' \
--header 'X-api-key: YOUR_API_KEY' \
--header 'X-delivery: BUILD_NUMBER' \
--header 'X-event: cd/ci' \ (cd for deployment, ci for build)
--header 'Content-Type: application/json' \
--data-raw '{
    "id": "unique-execution-id",
    "name": "Job Name",
    "pipelineId": "JobId",
    "timestamp": "2024-01-15T12:00:00Z",
    "startedAt": "2024-01-15T11:55:00Z",
    "completedAt": "2024-01-15T12:00:00Z",
    "htmlUrl": "Jenkins Build URL",
    "source": "jenkins",
    "status": "success",
    "repository": "your-repo-name",
    "artifact": "artifact-version",
    "environment": "production",
    "commit": "latest-commit-hash",        
    "tag": "test"
    "additionalInfo": {
        "label": "label1"
    },
    "stages": [{
        "name": "",
        "startTime": "",
        "endTime": "",
        "status": ""
    }]
}'

pipeline {
    agent any

    environment {
        REPOSITORY = 'simple-maven-project-with-tests.git'
        ENVIRONMENT = 'Production'
    }

    stages {
        stage('Build') {
            steps {
                script {
                    git 'https://github.com/jglick/simple-maven-project-with-tests.git'
                    sh 'mvn -Dmaven.test.failure.ignore=true clean package'
                }
            }

            post {
                success {
                    script {
                        def timeStamp = new Date().format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'')
                        def startTime = new Date().format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'')
                        def completedTime = new Date().format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'')
                        def scmVars = checkout([$class: 'GitSCM', branches: [[name: 'master']], 
                            userRemoteConfigs: [[url: 'https://github.com/jglick/simple-maven-project-with-tests.git']]])
                        
                        httpRequest contentType: 'APPLICATION_JSON', httpMode: 'POST', ignoreSslErrors: true, quiet: true, requestBody: """
                        {
                            "id": "${BUILD_NUMBER}",
                            "name": "${JOB_NAME}",
                            "pipelineId": "${JOB_ID}",
                            "timeStamp": "${timeStamp}",
                            "startedAt": "${startTime}",
                            "completedAt": "${completedTime}",
                            "commit": "${scmVars.GIT_COMMIT}",
                            "htmlUrl": "https://api.github.com/repos/devdynamics-ai/devd-client/deployments/696863512",
                            "source": "jenkins",
                            "status": "completed",
                            "repository": "${REPOSITORY}",
                            "environment": "${ENVIRONMENT}",
                            "branch": "${scmVars.GIT_BRANCH}",
                            "artifact": "",
                            "tag": "build-${BUILD_NUMBER}"
                            "additionalInfo": {},
                            "stages": [{
                                "name": "Build",
                                "startTime": "${startTime}",
                                "endTime": "${completedTime}",
                                "status": "completed"
                            }]
                        }
                        """, responseHandle: 'NONE', url: 'https://api.devdynamics.ai/api/v1/deployment/<your-devdynamics-orgId>/notify', wrapAsMultipart: false
                    }
                }
                failure {
                    script {
                        def timeStamp = new Date().format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'')
                        def startTime = new Date().format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'')
                        def completedTime = new Date().format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'')
                        def scmVars = checkout([$class: 'GitSCM', branches: [[name: 'master']], 
                            userRemoteConfigs: [[url: 'https://github.com/jglick/simple-maven-project-with-tests.git']]])
                        
                        httpRequest contentType: 'APPLICATION_JSON', httpMode: 'POST', ignoreSslErrors: true, quiet: true, requestBody: """
                        {
                            "id": "${BUILD_NUMBER}",
                            "name": "${JOB_NAME}",
                            "pipelineId": "${JOB_ID}",
                            "timeStamp": "${timeStamp}",
                            "startedAt": "${startTime}",
                            "completedAt": "${completedTime}",
                            "commit": "${scmVars.GIT_COMMIT}",
                            "htmlUrl": "https://api.github.com/repos/devdynamics-ai/devd-client/deployments/696863512",
                            "source": "jenkins",
                            "status": "failed",
                            "repository": "${REPOSITORY}",
                            "environment": "${ENVIRONMENT}",
                            "branch": "${scmVars.GIT_BRANCH}",
                            "artifact": "",
                            "tag": "build-${BUILD_NUMBER}"
                            "additionalInfo": {},
                            "stages": [{
                                "name": "Build",
                                "startTime": "${startTime}",
                                "endTime": "${completedTime}",
                                "status": "failed"
                            }]
                        }
                        """, responseHandle: 'NONE', url: 'https://api.devdynamics.ai/api/v1/deployment/<your-devdynamics-orgId>/notify', wrapAsMultipart: false
                    }
                }
            }
        }
    }
}

Support

For any questions, contact: support@devdynamics.ai

Last updated