├── Cucumber-Reporting-Pipeline-Stage.txt ├── Cucumber-Reporting-Pipeline.txt ├── Cucumber-Reporting.txt ├── DotNetPipeline.txt ├── Jenkins.ipynb ├── Pipeline.txt ├── Python-Jenkins-Pipeline.txt ├── Python-Jenkins.txt ├── README.md ├── SeleniumNUnitParam.txt └── jenkins-ci-dotnet.txt /Cucumber-Reporting-Pipeline-Stage.txt: -------------------------------------------------------------------------------- 1 | node('master') { 2 | // each block is a stage 3 | stage('checkout') { 4 | // add comment 5 | git 'https://github.com/nsadawi/awesome-bdd-with-cucumber.git' 6 | } 7 | stage('Maven Verify') { 8 | //add comment 9 | sh label: '', script: 'mvn clean verify' 10 | } 11 | stage('Generate Cucumber Report') { 12 | //add comment 13 | cucumber failedFeaturesNumber: -1, failedScenariosNumber: -1, failedStepsNumber: -1, fileIncludePattern: '**/*.json', jsonReportDirectory: 'target/', pendingStepsNumber: -1, skippedStepsNumber: -1, sortingMethod: 'ALPHABETICAL', undefinedStepsNumber: -1 14 | } 15 | } -------------------------------------------------------------------------------- /Cucumber-Reporting-Pipeline.txt: -------------------------------------------------------------------------------- 1 | node('master') { 2 | // no stages .. all steps in one go 3 | git 'https://github.com/nsadawi/awesome-bdd-with-cucumber.git' 4 | 5 | sh label: '', script: 'mvn clean verify' 6 | 7 | cucumber failedFeaturesNumber: -1, failedScenariosNumber: -1, failedStepsNumber: -1, fileIncludePattern: '**/*.json', jsonReportDirectory: 'target/', pendingStepsNumber: -1, skippedStepsNumber: -1, sortingMethod: 'ALPHABETICAL', undefinedStepsNumber: -1 8 | 9 | } -------------------------------------------------------------------------------- /Cucumber-Reporting.txt: -------------------------------------------------------------------------------- 1 | 2 | https://github.com/nsadawi/awesome-bdd-with-cucumber.git 3 | 4 | Build -> Top Level Maven -> verify -------------------------------------------------------------------------------- /DotNetPipeline.txt: -------------------------------------------------------------------------------- 1 | // Pipeline to Build .Net project 2 | node { 3 | 4 | stage("Checkout"){ 5 | git 'https://github.com/nsadawi/jenkins-ci-dotnet.git' 6 | } 7 | 8 | stage('Nuget'){ 9 | bat label: '', script: 'nuget restore src/MyWindowsService/' 10 | } 11 | 12 | stage('Build'){ 13 | bat "\"${tool 'MyMSBuild'}\" src/MyWindowsService/MyWindowsService/Deploy-Windows-Service-Via-MSBuild.proj" 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /Jenkins.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "#!pip install python-jenkins" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 5, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import jenkins\n", 19 | "import jenkinslogin" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 4, 25 | "metadata": { 26 | "scrolled": false 27 | }, 28 | "outputs": [ 29 | { 30 | "name": "stdout", 31 | "output_type": "stream", 32 | "text": [ 33 | "{'_class': 'hudson.model.User', 'absoluteUrl': 'http://localhost:8080/user/admin', 'description': None, 'fullName': 'Noureddin Sadawi', 'id': 'admin', 'property': [{'_class': 'jenkins.security.ApiTokenProperty'}, {'_class': 'com.cloudbees.plugins.credentials.UserCredentialsProvider$UserCredentialsProperty'}, {'_class': 'hudson.plugins.emailext.watching.EmailExtWatchAction$UserProperty', 'triggers': []}, {'_class': 'hudson.model.MyViewsProperty'}, {'_class': 'org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty'}, {'_class': 'hudson.model.PaneStatusProperties'}, {'_class': 'jenkins.security.seed.UserSeedProperty'}, {'_class': 'hudson.search.UserSearchProperty', 'insensitiveSearch': True}, {'_class': 'hudson.model.TimeZoneProperty'}, {'_class': 'hudson.security.HudsonPrivateSecurityRealm$Details'}, {'_class': 'hudson.tasks.Mailer$UserProperty', 'address': 'myemail@gmail.com'}, {'_class': 'jenkins.security.LastGrantedAuthoritiesProperty'}]}\n", 34 | "2.235.5\n" 35 | ] 36 | } 37 | ], 38 | "source": [ 39 | "server = jenkins.Jenkins('http://localhost:8080', username=jenkinslogin.username, password='admin')\n", 40 | "user = server.get_whoami()\n", 41 | "print(user)\n", 42 | "version = server.get_version()\n", 43 | "print(version)\n", 44 | "#dir(server)" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 3, 57 | "metadata": {}, 58 | "outputs": [ 59 | { 60 | "data": { 61 | "text/plain": [ 62 | "[{'_class': 'hudson.model.FreeStyleProject',\n", 63 | " 'name': 'CucumberFreestyleProject',\n", 64 | " 'url': 'http://localhost:8080/job/CucumberFreestyleProject/',\n", 65 | " 'color': 'blue',\n", 66 | " 'fullname': 'CucumberFreestyleProject'},\n", 67 | " {'_class': 'org.jenkinsci.plugins.workflow.job.WorkflowJob',\n", 68 | " 'name': 'CucumberPipelineProject',\n", 69 | " 'url': 'http://localhost:8080/job/CucumberPipelineProject/',\n", 70 | " 'color': 'blue',\n", 71 | " 'fullname': 'CucumberPipelineProject'},\n", 72 | " {'_class': 'hudson.model.FreeStyleProject',\n", 73 | " 'name': 'DockerNodeJS',\n", 74 | " 'url': 'http://localhost:8080/job/DockerNodeJS/',\n", 75 | " 'color': 'blue',\n", 76 | " 'fullname': 'DockerNodeJS'},\n", 77 | " {'_class': 'hudson.model.FreeStyleProject',\n", 78 | " 'name': 'SimpleMavenProject',\n", 79 | " 'url': 'http://localhost:8080/job/SimpleMavenProject/',\n", 80 | " 'color': 'blue',\n", 81 | " 'fullname': 'SimpleMavenProject'},\n", 82 | " {'_class': 'org.jenkinsci.plugins.workflow.job.WorkflowJob',\n", 83 | " 'name': 'SimpleMavenProjectPipeline',\n", 84 | " 'url': 'http://localhost:8080/job/SimpleMavenProjectPipeline/',\n", 85 | " 'color': 'blue',\n", 86 | " 'fullname': 'SimpleMavenProjectPipeline'}]" 87 | ] 88 | }, 89 | "execution_count": 3, 90 | "metadata": {}, 91 | "output_type": "execute_result" 92 | } 93 | ], 94 | "source": [ 95 | "#server.create_job('empty', jenkins.EMPTY_CONFIG_XML)\n", 96 | "jobs = server.get_jobs()\n", 97 | "jobs" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 18, 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [ 106 | "## Create a Free Style Project\n", 107 | "j = server.create_job('My Free Style', jenkins.EMPTY_CONFIG_XML)\n", 108 | "jobs = server.get_jobs()\n", 109 | "j" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 22, 115 | "metadata": {}, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "text/plain": [ 120 | "{'_class': 'hudson.model.User',\n", 121 | " 'absoluteUrl': 'http://localhost:8080/user/admin',\n", 122 | " 'description': None,\n", 123 | " 'fullName': 'Noureddin Sadawi',\n", 124 | " 'id': 'admin',\n", 125 | " 'property': [{'_class': 'jenkins.security.ApiTokenProperty'},\n", 126 | " {'_class': 'com.cloudbees.plugins.credentials.UserCredentialsProvider$UserCredentialsProperty'},\n", 127 | " {'_class': 'hudson.plugins.emailext.watching.EmailExtWatchAction$UserProperty',\n", 128 | " 'triggers': []},\n", 129 | " {'_class': 'hudson.model.MyViewsProperty'},\n", 130 | " {'_class': 'org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty'},\n", 131 | " {'_class': 'hudson.model.PaneStatusProperties'},\n", 132 | " {'_class': 'jenkins.security.seed.UserSeedProperty'},\n", 133 | " {'_class': 'hudson.search.UserSearchProperty', 'insensitiveSearch': True},\n", 134 | " {'_class': 'hudson.model.TimeZoneProperty'},\n", 135 | " {'_class': 'hudson.security.HudsonPrivateSecurityRealm$Details'},\n", 136 | " {'_class': 'hudson.tasks.Mailer$UserProperty',\n", 137 | " 'address': 'n.sadawi@gmail.com'},\n", 138 | " {'_class': 'jenkins.security.LastGrantedAuthoritiesProperty'}]}" 139 | ] 140 | }, 141 | "execution_count": 22, 142 | "metadata": {}, 143 | "output_type": "execute_result" 144 | } 145 | ], 146 | "source": [ 147 | "server.get_whoami()" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 17, 153 | "metadata": {}, 154 | "outputs": [ 155 | { 156 | "name": "stdout", 157 | "output_type": "stream", 158 | "text": [ 159 | "\n", 160 | " false\n", 161 | " \n", 162 | " \n", 163 | " true\n", 164 | " false\n", 165 | " false\n", 166 | " \n", 167 | " false\n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | "\n" 172 | ] 173 | } 174 | ], 175 | "source": [ 176 | "my_job = server.get_job_config('empty')\n", 177 | "print(my_job) # prints XML configuration" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": null, 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [ 186 | "server.build_job('empty')\n", 187 | "server.disable_job('empty')\n", 188 | "server.copy_job('empty', 'empty_copy')\n", 189 | "server.enable_job('empty_copy')\n", 190 | "server.reconfig_job('empty_copy', jenkins.RECONFIG_XML)" 191 | ] 192 | } 193 | ], 194 | "metadata": { 195 | "kernelspec": { 196 | "display_name": "Python 3", 197 | "language": "python", 198 | "name": "python3" 199 | }, 200 | "language_info": { 201 | "codemirror_mode": { 202 | "name": "ipython", 203 | "version": 3 204 | }, 205 | "file_extension": ".py", 206 | "mimetype": "text/x-python", 207 | "name": "python", 208 | "nbconvert_exporter": "python", 209 | "pygments_lexer": "ipython3", 210 | "version": "3.7.6" 211 | } 212 | }, 213 | "nbformat": 4, 214 | "nbformat_minor": 4 215 | } 216 | -------------------------------------------------------------------------------- /Pipeline.txt: -------------------------------------------------------------------------------- 1 | // Pipeline to Build .Net project 2 | node { 3 | 4 | stage("Checkout"){ 5 | git 'https://github.com/nsadawi/jenkins-ci-dotnet.git' 6 | } 7 | 8 | stage('Nuget'){ 9 | bat label: '', script: 'nuget restore src/MyWindowsService/' 10 | } 11 | 12 | stage('Build'){ 13 | bat "\"${tool 'MyMSBuild'}\" src/MyWindowsService/MyWindowsService/Deploy-Windows-Service-Via-MSBuild.proj" 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /Python-Jenkins-Pipeline.txt: -------------------------------------------------------------------------------- 1 | node('master') { 2 | // some block 3 | stage('Clone Python Proj from Github') { 4 | // some block 5 | git 'https://github.com/nsadawi/python-unittest-example.git' 6 | } 7 | stage('Create and Activate Python Virtual Env') { 8 | sh label: '', script: '''virtualenv .venv 9 | source .venv/bin/activate''' 10 | } 11 | stage('Install Required packages'){ 12 | sh label: '', script: '''pip install -r requirements.txt''' 13 | } 14 | stage('Run the Tests'){ 15 | sh label: '', script: '''nosetests tests''' 16 | } 17 | stage('Deactivate Python Virtual Env'){ 18 | sh label: '', script: '''deactivate''' 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Python-Jenkins.txt: -------------------------------------------------------------------------------- 1 | https://github.com/nsadawi/python-unittest-example.git 2 | 3 | virtualenv .venv 4 | source .venv/bin/activate 5 | pip install -r requirements.txt 6 | nosetests tests 7 | deactivate -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This repo is for my Jenkins Primer course 2 | 3 | Some example configurations and commands are included here .. they are explained during the course -------------------------------------------------------------------------------- /SeleniumNUnitParam.txt: -------------------------------------------------------------------------------- 1 | SCM 2 | https://github.com/nsadawi/Jenkins-DotNet-SeleniumNUnitParam.git 3 | 4 | Build -> Windows Batch Command 5 | "C:\ProgramData\chocolatey\bin\nuget.exe" restore SeleniumNUnitParam.sln 6 | 7 | MSBuild 8 | Build File -> SeleniumNUnitParam.sln 9 | 10 | Build -> Windows Batch Command 11 | C:\ProgramData\chocolatey\bin\nunit3-console.exe "SeleniumNUnitParam/bin\Debug/SeleniumNUnitParam.dll" -------------------------------------------------------------------------------- /jenkins-ci-dotnet.txt: -------------------------------------------------------------------------------- 1 | Source Code Management 2 | https://github.com/nsadawi/jenkins-ci-dotnet.git 3 | 4 | Windows Batch Command 5 | nuget restore src/MyWindowsService/ 6 | 7 | VS MSBuild 8 | src/MyWindowsService/MyWindowsService/Deploy-Windows-Service-Via-MSBuild.proj --------------------------------------------------------------------------------