Saturday, May 29, 2021

Powershell and TFS

Powershell to create TFS work items 











To identify properties 

$Bug_workitem.save gives the return type and arguments 
$Bug_woritem.Fields --> to list the fields 

To view a specif type of fields with vaues 

$temp_val = $Bug_workitem.Fields | Where-Object name -eq state
Temp_Val.Allowedvalues

To view workitem types 

$WorkItemStore.Projects["Workitem"].WorkItemTypes


Command line for TFS 

https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/54dkh0y3(v=vs.90)


TFS for Linux 

https://www.microsoft.com/en-us/download/details.aspx?id=30661


https://stackoverflow.com/questions/5503858/how-to-get-tf-exe-tfs-command-line-client


Setting up new project

 a. Make sure the folder and file name are in small letter or camel case . Avoid special characters in the file and folder name.
 b. Make sure the folder and file name does not have spaces.
 c. Make sure the file extension is all small letters(.sql, .java,.ts,.html)
 d. If a function (database, java, angular) or stored procedure is used more than one then create as common
 e. Try to maintain master table for associating the files to Task like tbl_service_master etc.
 f. Instead of Sqlite kindly use relational database as much as possible for thitd party prodcuts like Helix ALM.
g. Defect status should be like following in the environment Assuming we have environments like DEV, UIT  and SIT
      Environment : DEV
              New --> when a defect is created 
              Dev-InProgress --> when a developer is working on the defect 
              Dev-Completed  --> when a developer assumes he is done with development of the defect
              Ready for UIT build  --> To build in UIT environment the code is ready
              UIT build inProgess --> when build is happening so end user know that the defect is included as part of the build.
              UIT Test InProgress --> The defect is eligible for  testing in UIT region.
              UIT Completed        --> Tester or Developer has verified and  passed the test          
              Ready for SIT build --> To make the defect is ready for next code promotion
              SIT build InProgress --> Currently build is happening with this defect 
              SIT Test InProgress   --> Currently Tester is testing in SIT region
   h. For Selenium have the database queries in json file instead of Excel so it will be easy for troubleshooting in linux environment.
  i.  For Database we have following 
       i. DDL --> Create table and these will be modified through out the project
      ii. DML --> We will define 
 
 

Sunday, May 16, 2021

Jenkins

To know the environment variables

http://<<system-name>>:8080/env-vars.html

http://localhost:8080/env-vars.html

To know the API of Jenkins

http://localhost:8080/api/

Basic Jenkins example
https://www.theserverside.com/tutorial/Create-a-Jenkins-build-job-A-CI-tutorial-for-beginners

To invoke a build on a project we need to form the REST API as below

JENKINS_URL/job/JOB_NAME/build

Path :  http://192.168.43.103:8080/job/FirstSample/build

For more details in term of build refer below

https://wiki.jenkins.io/display/JENKINS/Remote+access+API

Jenkins hand book



Jenkins Shared library

Sudoers file when using sudo command 


Lock and Milestone


To get crumb

curl -u "admin:admin" 'http://192.168.43.103:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'

CSRF Protection
https://support.cloudbees.com/hc/en-us/articles/219257077-CSRF-Protection-Explained
https://wiki.jenkins.io/display/JENKINS/CSRF+Protection

how to work out CSRF issue
https://stackoverflow.com/questions/38137760/jenkins-rest-api-create-job


To restart Jenkins from console
JENKINS_URL/restart 
Eg: http://192.168.43.103:8080/restart

More details about Jenkins restart
https://stackoverflow.com/questions/8072700/how-to-restart-jenkins-manually


To start and stop Jenkins from Linux use the below command

systemctl stop jenkins  --> To stop jenkins
systemctl start jenkins --> to start jenkins
systemctl status Jenkins --> to know the status

In suse Linux below commands will work

sudo service jenkins status

sudo service jenkins stop

sudo service jenkins start

sudo service jenkins restart 

In the Linux the war file is present in the below location

/usr/lib/Jenkins/


To get the a specific version war file in Linux use the below command

cd tmp
mkdir download
wget http://updates.jenkins-ci.org/download/war/2.204/jenkins.war

wget http://updates.jenkins-ci.org/download/war/<<version_number>>/jenkins.war


Reference links for building REST API call
https://support.cloudbees.com/hc/en-us/articles/218889337-How-to-build-a-job-using-the-REST-API-and-cURL-

https://support.cloudbees.com/hc/en-us/articles/220857567-How-to-create-a-job-using-the-REST-API-and-cURL-

https://stackoverflow.com/questions/8512807/calling-a-jenkins-build-from-outside-of-jenkins


WAS and Jenkins

https://aboullaite.me/continuous-deployment-with-maven-jenkins-and-was/

To pause the deployment you can use option as input

To have the input in script then use the below

 script {
                            input message: "Proceed or Abort",
                            submitter: "selenium,admin",
                            ok : "Yes, Proceed."
                           //parameters: [
                             //           string( name:'username',
                               //                 defaultValue: 'user1',
                                 //               description: 'Username of the user pressing Ok')]
                    }

https://jenkins.io/doc/book/pipeline/syntax/#input

******************************************************************
Declarative vs Scripted Pipeline

https://e.printstacktrace.blog/jenkins-scripted-pipeline-vs-declarative-pipeline-the-4-practical-differences/

https://www.jenkins.io/doc/book/pipeline/syntax/

https://medium.com/@brianrthompson/scripted-vs-declarative-pipelines-which-to-choose-c6af403f1e97

https://www.edureka.co/community/54705/difference-between-declarative-pipeline-scripted-pipeliine

**************************************************************************
Shared library in

https://devopscube.com/jenkins-shared-library-tutorial/

https://devopscube.com/create-jenkins-shared-library/

https://tomd.xyz/jenkins-shared-library/

https://jenkins.io/doc/book/pipeline/shared-libraries/

https://jenkins.io/blog/2019/01/08/mpl-modular-pipeline-library/

https://medium.com/@AndrzejRehmann/private-jenkins-shared-libraries-540abe7a0ab7

https://medium.com/spaceapetech/jenkins-pipelines-25ebc1980600

https://stackoverflow.com/questions/46507962/how-can-i-call-a-script-in-the-resources-folder-with-arguments-in-a-jenkinsfile

https://stackoverflow.com/questions/59316211/calling-script-from-resource-folder-in-jenkins-shared-folder

https://stackoverflow.com/questions/40213654/how-to-invoke-bash-functions-defined-in-a-resource-file-from-a-jenkins-pipeline
*************************************************************

shared library best practice

https://bmuschko.com/blog/jenkins-shared-libraries/

https://github.com/jenkinsci/JenkinsPipelineUnit/issues/51

https://github.com/stchar/pipeline-sharedlib-testharness/blob/master/jobs/hello.groovy

http://tdongsi.github.io/blog/2017/12/26/class-in-jenkins-shared-library/

https://stackoverflow.com/questions/51326983/using-jenkins-dynamic-shared-lib-into-pipeline



slave and master

https://github.com/salemove/pipeline-lib

https://embeddedartistry.com/blog/2018/01/11/jenkins-configuring-a-linux-slave-node/





Useful material
https://www.eficode.com/blog/jenkins-groovy-tutorial


to get the changes from last build to current build 
https://support.cloudbees.com/hc/en-us/articles/217630098-How-to-access-Changelogs-in-a-Pipeline-Job-


 checkout([$class: 'TeamFoundationServerScm',
                        credentialsConfigurer: [$class: 'AutomaticCredentialsConfigurer'],
                        projectPath: '$/STG',
                        serverUrl: TFS_SERVER,
                        workspaceName: '${JOB_NAME}-${NODE_NAME}'])
                    script{
                        println("currentBuild : "+currentBuild);
                       
                        def changedFiles = []
                        def changeLogSets = currentBuild.changeSets
                        for (entries in changeLogSets) {
                            for (entry in entries) {
                               for (file in entry.affectedFiles) {
                                 echo "Found changed file: ${file.path}"
                                 changedFiles += "${file.path}"
                                }
                           }
                       }
                    }


https://stackoverflow.com/questions/6260383/how-to-get-list-of-changed-files-since-last-build-in-jenkins-hudson

https://stackoverflow.com/questions/38084806/how-to-get-the-changes-since-the-last-successful-build-in-jenkins-pipeline

https://support.cloudbees.com/hc/en-us/articles/217630098-How-to-access-Changelogs-in-a-Pipeline-Job-

Jenkins environment variables

https://code-maven.com/jenkins-pipeline-environment-variables

****************************************************************
We can now communicate Linux  and windows using powershell 
Install powershell in linux 

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1

https://en.opensuse.org/PowerShell

Install the following plugins as well verify before installing the plugins 
 Powershell 
 envinject

************************************************************

Jenkins shared library 

https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Jenkins-Shared-Library-GitHub-Example-Pipeline
https://www.codurance.com/publications/2019/05/25/private-jenkins-shared-libraries
https://devopscube.com/jenkins-shared-library-tutorial/

*****************************************************************
To start slave 
https://pravinrajput.wordpress.com/2016/08/02/configure-jenkins-slave-and-connect-to-master/
https://wiki.jenkins.io/display/JENKINS/Step+by+step+guide+to+set+up+master+and+agent+machines+on+Windows

*****************************************************

Parallel, stash , unstash
how to avoid @2 or temp for projects

***************************

Variables usage from Jenkins pipeline to shellscript 

 for (i in [ 'a', 'b', 'c' ]) {
                        echo i
                        sh """
                        echo "from shell i=${i}"
                        """
                        sh '''
                        echo "from shell i='''+i+''' check"
                        '''
                         sh '''
                        echo "from shell i='''+"${i}"+''' check"
                        '''
                    }

https://stackoverflow.com/questions/41539076/how-to-pass-variables-from-jenkinsfile-to-shell-command

https://stackoverflow.com/questions/40323490/passing-variable-to-bash-script-in-a-jenkins-pipeline-job

*********************************************************

how to set environment variable in scripted pipeline

https://stackoverflow.com/questions/55123079/how-to-set-environment-variables-in-a-jenkins-scripted-pipeline

Tuesday, May 4, 2021

DB2 and ssl connection

 how to connect to ssl enabled db2 

http://fm4dd.com/database/howto-encrypt-IBMdb2-jdbc.shtm

Using the below we have used ARM file 

https://www.ibm.com/support/pages/node/1077081


Certificate formats 

https://www.ibm.com/docs/en/sia?topic=osdc-certificate-key-formats-23



Saturday, May 1, 2021

personal

 Principal backup codes of pavan


95881324

27860223

01095749

00372824

54688514

01275539

75605923

24465484

07218094

00831099