visit
docker pull jenkins/jenkins:lts
lts: Pulling from jenkins/jenkins
844c33c7e6ea: Pull complete
ada5d61ae65d: Pull complete
f8427fdf4292: Pull complete
f025bafc4ab8: Pull complete
67b8714e1225: Pull complete
64b12da521a3: Pull complete
2e38df533772: Pull complete
b1842c00e465: Pull complete
b08450b01d3d: Pull complete
2c6efeb9f289: Pull complete
0805b9b9cdc4: Pull complete
f129619fc383: Pull complete
cd27f3a82cdf: Pull complete
f31251f493ed: Pull complete
2c902f1f4dfa: Pull complete
2fe1d2cb7aab: Pull complete
908723de775f: Pull complete
54aa3899e429: Pull complete
f48cf8764dc1: Pull complete
Digest: sha256:d5069c543e80454279caacd13457d012fb32c5229b5037a163d8bf61ffa6b80b
Status: Downloaded newer image for jenkins/jenkins:lts
alis-MBP:scms aliyuksel$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jenkins/jenkins lts a3f949e5ebfd 2 weeks ago 582MB
docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
-v
means Volume. If there is no volume it creates automatically. You can look at for additional information. Basically we define new volume that is name jenkins_home and mount the path which is in container file system that is /var/jenkins_home
. After that when we shut down container, our changes do not fly. Because all files under /var/jenkins_home
folder keep into Volume. Now we can call url of Jenkins on browser. Jenkins says that we should be unlock it. We need initialAdminPassword. When we execute above command we can see logs. In these logs we can see initialAdminPassword.
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
fb7b0666b23f40db985817700d1d0821
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
docker pull alpine
-v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker)
docker.sock file is used for socket listening. After added these volumes to command line, "
docker.sock
" mounted to "docker.sock
" in localmachine. If we use -v
with real path on the localmachine, it means mount. And if we use $() , it means run command. -v $(which docker):$(which docker)
means, if "which docker" runs on container , docker runs "which container" on localmachine and returns result to container. We have to add this parameter because jenkins runs "which docker" to find docker.We have to change privileges of this file because jenkins user can't acces this file. We need connect to container with root user.we can run this command and run container. docker run -p 8080:8080 -p 50000:50000 --name jenkins -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) jenkins/jenkins:lts
docker container rm jenkins
After that you can use
--name
jenkins next time.We can implement pipeline now. Click "New Item" under menu. Enter an Item Name. Select PipeLine and click ok.pipeline {
agent {
docker { image 'alpine' }
}
stages {
stage('pull project') {
steps {
sh 'pwd'
}
}
}
}
pipeline {
agent {
docker { image 'alpine' }
}
stages {
stage('pull project') {
steps {
git credentialsId : 'aliyksel', url:'//[email protected]/allscms/scms.git'
}
}
}
}
docker pull node
docker run -it --name node node bash
npm install serverless -g
docker commit node serverlessimg
exit
agent {
docker { image 'serverlessimg' }
}
...
stage('pull and deploy project : scms') {
steps {
git credentialsId : 'aliyksel', url:'//[email protected]/allscms/scms.git'
sh 'npm install'
sh 'serverless config credentials --provider aws --key AKIAIOSFODNN7EXAMPLE --secret wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
sh 'serverless deploy'
}
}
}
serverless config credentials --provider aws --key AKIAIOSFODNN7EXAMPLE --secret wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY