Changeset - ad275fcc5a90
[Not reviewed]
default
0 1 0
domruf - 9 years ago 2017-03-23 22:20:35
dominikruf@gmail.com
jenkinsfile: create venv in special folder instead of jenkins workspace

The path to a jenkins workspace tends to get very long. But the maximum for a
shebang line is usually 127 characters. This can cause problems with git hook
scripts or when calling pip. To avoid these problems create the virtualenv
in the a folder under $JENKINS_HOME which is usually much shorter.
1 file changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
Jenkinsfile
Show inline comments
 
node {
 
    def createvirtualenv = ''
 
    def activatevirtualenv = ''
 
    if (isUnix()) {
 
        activatevirtualenv = '. venv/bin/activate'
 
        createvirtualenv = 'rm -r $JENKINS_HOME/venv/$JOB_NAME || true && virtualenv $JENKINS_HOME/venv/$JOB_NAME'
 
        activatevirtualenv = '. $JENKINS_HOME/venv/$JOB_NAME/bin/activate'
 
    } else {
 
        activatevirtualenv = 'call venv\\Scripts\\activate.bat'
 
        createvirtualenv = 'rmdir /s /q %JENKINS_HOME%\\venv\\%JOB_NAME% || true && virtualenv %JENKINS_HOME%\\venv\\%JOB_NAME%'
 
        activatevirtualenv = 'call %JENKINS_HOME%\\venv\\%JOB_NAME%\\Scripts\\activate.bat'
 
    }
 

	
 
    stage('checkout') {
 
        checkout scm
 
        if (isUnix()) {
 
            sh 'hg --config extensions.purge= purge --all'
 
        } else {
 
            bat 'hg --config extensions.purge= purge --all'
 
        }
 
    }
 
    stage('virtual env') {
 
        def virtualenvscript = """virtualenv venv
 
        def virtualenvscript = """$createvirtualenv
 
            $activatevirtualenv
 
            python -m pip install --upgrade pip
 
            pip install --upgrade setuptools
 
            pip install --upgrade pylint
 
            pip install --upgrade pytest-cov
 
            """
0 comments (0 inline, 0 general)