0

Trying to recognize how I can run the python script which is located on GitHub https://github.com/rix0rrr/cover2cover on Jenkins pipeline

In readme documentation I see 'Add the following "post step" to your Jenkins build:' and command mkdir -p target/site/cobertura && cover2cover.py target/site/jacoco/jacoco.xml src/main/java > target/site/cobertura/coverage.xml

I am not really familiar with Jenkins and python, so from my understanding before the command above

  1. I need somehow to download the script into the Jenkins workspace? Or any possibility to recognize it without downloading it?
  2. Have Jenkins tool for cloning/downloading from Github?
  3. Should I wrap this command into something like this sh mkdir folder sh python cover2cover.py

1 Answer 1

1

You can set up a Jenkins pipeline with a checkout step (official docs). You should also check this blog post on how to do this. In your case it would look something like this:

dir('somedir'){
    checkout ([
        $class: 'GitSCM',
        branches:[[name: "master"]],
        doGenerateSubmoduleConfigurations: false,
        extensions: [
            [$class: 'CleanCheckout']
        ],
        submoduleCfg: [],
        userRemoteConfigs: [[
            url: 'https://github.com/rix0rrr/cover2cover.git',
            credentialsId: ''     <--- put your credentials here if necessary
        ]]
    ])
}

Since I added dir('somedir') at the top, this would get checked out into somedir, and you can then run:

mkdir -p target/site/cobertura && cover2cover.py target/site/jacoco/jacoco.xml src/main/java > target/site/cobertura/coverage.xml
Sign up to request clarification or add additional context in comments.

2 Comments

Should I wrap it agent { docker { image 'python:3.10.1-alpine' } } on script call or is it redundant?
If you already have python in your Jenkins system then it should not be necessary

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.