简体   繁体   中英

How to execute local python scripts in jenkins through maven

I am new to Jenkins, And need to execute some python scripts stored in my local machine through maven in Jenkins. Could some one guide me about this.

If you want to execute a python script through maven you don't have to worry about Jenkins. Because from Jenkins you will be executing maven commands and maven will take care of executing the Python script. For this you can use something like the maven exec plugin . But if you want to execute a python command before executing the maven command you can use a shell executor for this. Following is a sample pipeline for this.

pipeline {
    agent any

    stages {
        stage('Sample') {
            steps {
                script {
                    git branch: 'master'
                        url: 'git@github.com:ycr/sample.git'
                   }
                    sh """
                        python hello.py // Execute python
                        mvn clean install // Execute maven
                    """
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM