0

I have the following code which works in gitlab (without the sh part):

sh '''
mkdir ./pylint
docker run --rm --entrypoint=/usr/local/bin/pylint ${IMAGE_NAME}:${IMAGE_VERSION} --rcfile=.pylintrc --exit-zero ${MODULE} > ./pylint/pylint.log
PYLINT_SCORE=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' ./pylint/pylint.log)
'''

what it does, it takes the value 8.52 from this output: Your code has been rated at 8.52/10

I'm trying also to use it in Jenkinsfile, but gets the following exception:

WorkflowScript: 50: unexpected char: '\' @ line 50, column 75.
   /^Your code has been rated at \([-0-9.]*

any idea how to fix it? or use other command from sed to get the require output?

arielma
  • 101

1 Answers1

0

The correct command is:

PYLINT_SCORE=$(sed -n 's#^Your code has been rated at \\([-0-9.]*\\)/.*#\\1#p' ./pylint/pylint.log)

arielma
  • 101