Kai5174 / JenkinsLearning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jenkins

Installation

Install Jenkins in the docker

docker pull jenkins

Run jenkins with assgined port 49001:8080

docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home:z -t jenkins

Visit localhost:49001 and config the jenkins.

Get InitialAdminPassword

Find the id of jenkins instance

docker ps -a

Get the shell of that instance, in here, my instance id is 26f8fda57fad

docker exec -it 26f8fda57fad bash

Then you should be able to obtain the InitialAdminPassword

Pipeline

View Official Doc for more information

Create new file Jenkinsfile with content (This is for naive implementation, the example is in my git repository here)

pipeline {
    agent { docker 'python:3.5.1' }
    stages {
        stage('build') {
            steps {
                sh 'python --version'
                sh 'ls'
            }
        }
    }
}

push it into your git repository.

git push origin master

Then go to the localhost:49001, choose new Item, with multiPipelines properties, then config the rules and access credential. Now the Jenkins should be work

About