Giter Site home page Giter Site logo

Comments (3)

michael-baron avatar michael-baron commented on June 17, 2024

Hi,

The plugin requires the path for the location of the Klocwork tools to be set. For a pipeline job you can add:

PATH = "/tmp/klocwork/latest/bin:$PATH"

to the environment section of your pipeline. This should resolve the issue with the location of the tools being unknown.

Best Regards,

Michael

from klocwork-plugin.

grzegorz-kotarski avatar grzegorz-kotarski commented on June 17, 2024

Hi,

The plugin requires the path for the location of the Klocwork tools to be set. For a pipeline job you can add:

PATH = "/tmp/klocwork/latest/bin:$PATH"

to the environment section of your pipeline. This should resolve the issue with the location of the tools being unknown.

Best Regards,

Michael

Hi Michael,

It does not work, it looks like it is related to https://issues.jenkins.io/browse/JENKINS-48082

See example pipeline code:

stage('Docker') {
        agent {
          docker {
            image '<MY_IMAGE>'
          }
        }
        steps {
            echo 'Docker:'
            withEnv(['PATH+WHATEVER=/tmp/klocwork']) {
                echo "env.PATH=${env.PATH}"
                sh 'echo sh PATH = $PATH'
                sh '''#!/usr/bin/env bash
                echo bash PATH = $PATH
                '''
            }
        }
    }
    stage('Master') {
        agent {
          label 'master'
        }
        steps {
            echo 'Master:'
            withEnv(['PATH+WHATEVER=/tmp/klocwork']) {
                echo "env.PATH=${env.PATH}"
                sh 'echo sh PATH = $PATH'
                sh '''#!/usr/bin/env bash
                echo bash PATH = $PATH
                '''
            }
        }
    }

The result of its execution is:

$ docker run -t -d -u 1002:120 -v /home/jenkins/.ssh:/home/jenkins/.ssh -w /home/jenkins/workspace/my-pipeline -v /home/jenkins/workspace/my-pipeline:/home/jenkins/workspace/my-pipeline:rw,z -v /home/jenkins/workspace/my-pipeline_tmp:/home/jenkins/workspace/my-pipeline_tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** <MY_IMAGE> cat
$ docker top ae03c529a78bd9a947bb948bd5e9c428343997de60305d4b741f722d07712345 -eo pid,comm
[Pipeline] {
[Pipeline] echo
Docker:
[Pipeline] withEnv
[Pipeline] {
[Pipeline] echo
env.PATH=/tmp/klocwork:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
[Pipeline] sh
+ echo sh PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
sh PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[Pipeline] sh
bash PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
$ docker stop --time=1 ae03c529a78bd9a947bb948bd5e9c428343997de60305d4b741f722d07712345
$ docker rm -f ae03c529a78bd9a947bb948bd5e9c428343997de60305d4b741f722d07712345
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Master)
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/my-node
[Pipeline] {
[Pipeline] echo
Master:
[Pipeline] withEnv
[Pipeline] {
[Pipeline] echo
env.PATH=/tmp/klocwork:/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[Pipeline] sh
+ echo sh PATH = /tmp/klocwork:/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
sh PATH = /tmp/klocwork:/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[Pipeline] sh
bash PATH = /tmp/klocwork:/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

As you can see for docker the env. variable has not changed.

Best Regards,
Greg

from klocwork-plugin.

grzegorz-kotarski avatar grzegorz-kotarski commented on June 17, 2024

An "ugly" workaround would be to set the PATH variable using docker args:

docker {
    image '<MY_IMAGE>'
    args '-e PATH=$PATH:/tmp/klocwork/latest/bin'

from klocwork-plugin.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.