diff --git a/integrations/Jenkins/Jenkinsfile b/integrations/Jenkins/Jenkinsfile new file mode 100644 index 0000000..893d303 --- /dev/null +++ b/integrations/Jenkins/Jenkinsfile @@ -0,0 +1,92 @@ +def label = "worker-${UUID.randomUUID().toString()}" + +properties( + [parameters( + [ + string(defaultValue: 'IoT_API', description: '', name: 'CMA_APPLICATION_NAME', trim: false), + choice(choices: ['configmyappdemo-2044no-uzyczrm0.appd-cx.com', 'dev-configmyappdemo-2044no-uzyczrm0.appd-cx.com'], description: 'Select AppDynamics Controller', name: 'CMA_CONTROLLER_HOST'), + choice(choices: ['customer1', 'dev-customer1'], description: 'Select AppDynamics Account', name: 'CMA_ACCOUNT'), + string(defaultValue: '8090', description: 'Controller Port', name: 'CMA_CONTROLLER_PORT', trim: true), + booleanParam(defaultValue: 'false', description: 'Use HTTPS?', name: 'CMA_USE_HTTPS', trim: false), + booleanParam(defaultValue: false, description: 'Include Server visibility', name: 'CMA_INCLUDE_SIM'), + booleanParam(defaultValue: false, description: 'Configure ONLY Buisness transactions', name: 'CMA_BT_ONLY'), + booleanParam(defaultValue: false, description: 'Add Business Transactions', name: 'CMA_CONFIGURE_BT'), + booleanParam(defaultValue: false, description: 'Include Database', name: 'CMA_INCLUDE_DATABASE'), + string(defaultValue: 'app-db', description: 'If Include DB, set DB collector name', name: 'CMA_DATABASE_NAME', trim: false), + booleanParam(defaultValue: false, description: 'Overwrite Existing Health Rules', name: 'CMA_OVERWRITE_HEALTH_RULES') + ]) + ] +) + +node { + // Clean workspace before doing anything + deleteDir() + try { + + stage ('Clone') { + checkout scm + } + + stage('ConfigMyApp') { + + withCredentials([usernamePassword(credentialsId: 'controller_credentials', passwordVariable: 'CMA_PASSWORD', usernameVariable: 'CMA_USERNAME')]) { + sh """ + echo "ConfigMyApp...start " + export CMA_APPLICATION_NAME=${params.CMA_APPLICATION_NAME} + export CMA_CONTROLLER_HOST=${params.CMA_CONTROLLER_HOST} + export CMA_USE_HTTPS=${params.CMA_USE_HTTPS} + export CMA_CONTROLLER_PORT=${params.CMA_CONTROLLER_PORT} + export CMA_BT_ONLY=${params.CMA_BT_ONLY} + export CMA_ACCOUNT=${params.CMA_ACCOUNT} + export CMA_INCLUDE_SIM=${params.CMA_INCLUDE_SIM} + export CMA_CONFIGURE_BT=${params.CMA_CONFIGURE_BT} + export CMA_INCLUDE_DATABASE=${params.CMA_INCLUDE_DATABASE} + + LOCATION=\$(curl -s https://api.github.com/repos/Appdynamics/ConfigMyApp/releases/latest \ + | grep "tag_name" \ + | awk '{print "https://github.com/Appdynamics/ConfigMyApp/archive/" substr(\$2, 2, length(\$2)-3) ".zip"}') \ + ; curl -L -o ConfigMyApp.zip \$LOCATION + + ls -ltr + + # apt-get install unzip -y + unzip ConfigMyApp.zip + cd ConfigMyApp-* + + #Branding + + background="https://user-images.githubusercontent.com/2548160/90539325-97103100-e177-11ea-975a-6ae777ae03e3.jpg" + curl -o "branding/background.jpg" \$background + logo="https://user-images.githubusercontent.com/2548160/90539333-98d9f480-e177-11ea-99b9-8b72a2fe525a.png" + curl -o "branding/logo.png" \$logo + + pwd + + ls ${workspace}@script/ + + ls ${workspace} + + if [ "\$CMA_BT_ONLY" = true ] || [ "\$CMA_CONFIGURE_BT" = true ]; then + cp ${workspace}/bt_config/${params.CMA_APPLICATION_NAME}-configBT.json bt_config/configBT.json + fi + + #ls -ltr + + echo "Start script" + if [ "\$CMA_INCLUDE_DATABASE" = true ]; then + ./start.sh --include-database --database-name='${params.CMA_DATABASE_NAME}' --overwrite-health-rules --use-branding --logo-name="logo.png" --background-name="background.jpg" + else + ./start.sh --overwrite-health-rules --use-branding --logo-name="logo.png" --background-name="background.jpg" --debug + fi + echo "End script" + """ + + } + } + }catch (err) { + currentBuild.result = 'FAILED' + throw err + } + } + + diff --git a/integrations/Jenkins/README.md b/integrations/Jenkins/README.md deleted file mode 100644 index 7a2a95d..0000000 --- a/integrations/Jenkins/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Jenkins - -Jenkins is a free and open source automation server. -It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. - -## Prerequisite - -Verify that you are having Docker Compose installed: - ``` - docker-compose --version - ``` - -## Run Jenkins as Docker Constainer - -To start a local Jenkins server navigate to Jenkins folder and start the containers defined in docker-compose.yaml file: - ``` - cd /integrations/Jenkins - docker-compose up -d - ``` - -In order to show running containers, use the following command: - ``` - docker ps - ``` - -Jenkins is running on localhost:8080 and you can access it in the browser. - -Since volumes are mounted, note that all of your data configurations, plugins, pipelines, passwords, etc. will be persisted on the machine where containers are stared from. - -For more information about running Jenkins in Docker container refer to the official documentation: https://www.jenkins.io/doc/book/installing/#downloading-and-running-jenkins-in-docker - -## Unlock Jenkins - -If you are starting the Jenkins container for the first time, in order to check for your password, access the container logs in the following way: - - ``` - docker logs CONTAINER_ID - ``` - -And copy and paste the password from container to a Jenkins web form input field when prompted. - -More details about Unlocking Jenkins can be found here: https://www.jenkins.io/doc/book/installing/#unlocking-jenkins \ No newline at end of file diff --git a/integrations/Jenkins/jenkins-ui.png b/integrations/Jenkins/jenkins-ui.png new file mode 100644 index 0000000..cb827c5 Binary files /dev/null and b/integrations/Jenkins/jenkins-ui.png differ diff --git a/integrations/azure-devops/azure-devops.png b/integrations/azure-devops/azure-devops.png new file mode 100644 index 0000000..b62ff98 Binary files /dev/null and b/integrations/azure-devops/azure-devops.png differ diff --git a/integrations/azure-devops/azure-pipelines.yml b/integrations/azure-devops/azure-pipelines.yml new file mode 100644 index 0000000..d9c393f --- /dev/null +++ b/integrations/azure-devops/azure-pipelines.yml @@ -0,0 +1,80 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + + +trigger: +- master +pool: + vmImage: 'ubuntu-latest' + environment: + name: 'CMA' + tags: configmyapp + +# Set variables once as shown below, use the UI +variables: + #CMA_APPLICATION_NAME: IoT_API + CMA_CONTROLLER_HOST: configmyappdemo-2044no-uzyczrm0.appd-cx.com + CMA_CONTROLLER_PORT: 8090 + CMA_ACCOUNT: customer1 + CMA_USE_HTTPS: false + CMA_USERNAME: appd + CMA_CONFIGURE_BT: true + #CMA_INCLUDE_SIM: true + #CMA_BT_ONLY: false + #CMA_INCLUDE_DATABASE : false + #CMA_OVERWRITE_HEALTH_RULES: true + #CMA_DATABASE_NAME: ConfigMyApp + +steps: +- script: | + # Write your commands here + + LOCATION=$(curl -s https://api.github.com/repos/Appdynamics/ConfigMyApp/releases/latest \ + | grep "tag_name" \ + | awk '{print "https://github.com/Appdynamics/ConfigMyApp/archive/" substr($2, 2, length($2)-3) ".zip"}') \ + ; curl -L -o ConfigMyApp.zip $LOCATION + + pwd + ls -ltr + # apt-get install unzip -y + unzip ConfigMyApp.zip + cd ConfigMyApp-* + + #Branding # + + #Get it from a remote location + + #background="https://user-images.githubusercontent.com/2548160/88209855-36123d80-cc4b-11ea-8a46-8bf8bd02bbb5.jpg" + #curl -o "branding/background.jpg" $background + #logo="https://user-images.githubusercontent.com/2548160/88204707-9a310380-cc43-11ea-9149-561199f144af.png" + #curl -o "branding/logo.png" $logo + + #OR copy the files from git + + cp ../branding/background.png branding/background.png + cp ../branding/logo.png branding/logo.png + + echo CMA_BT_ONLY = $CMA_BT_ONLY + echo CMA_CONFIGURE_BT = $CMA_CONFIGURE_BT + + if [ "$CMA_BT_ONLY" = true ] || [ "$CMA_CONFIGURE_BT" = true ]; then + cp ../bt_config/$CMA_APPLICATION_NAME-configBT.json bt_config/configBT.json + ./start.sh --include-database --database-name="$CMA_DATABASE_NAME" --use-branding --logo-name="logo.png" --background-name="background.png" + else + ./start.sh --use-branding --logo-name="logo.png" --background-name="background.png" + fi + echo "End script##" + displayName: 'Run ConfigMyApp' + env: + CMA_PASSWORD: $(CMA_PASSWORD) + CMA_APPLICATION_NAME: $(CMA_APPLICATION_NAME) + CMA_INCLUDE_SIM: $(CMA_INCLUDE_SIM) + CMA_CONFIGURE_BT: $(CMA_CONFIGURE_BT) + CMA_BT_ONLY: $(CMA_BT_ONLY) + CMA_INCLUDE_DATABASE: $(CMA_INCLUDE_DATABASE) + CMA_DATABASE_NAME: $(CMA_DATABASE_NAME) + CMA_OVERWRITE_HEALTH_RULES: $(CMA_OVERWRITE_HEALTH_RULES) + +