Olá pessoal,
Tenho um script em python que auxilia em algumas tarefas no meu processo de integração continua e meu jenkins está executando em windows.
Tenho um job que eu criei para realizar o teste de execução desse script, mas estou encontrando problemas em poder executa-lo com o jenkins.
Basicamente na sessão Build eu executo os comando abaixo no windows:
SET PATH=%PATH%;%PYTHON_PATH%
call python C:/tools/libs/directory.py
call python create_directory('c:/temp/versions', 'ingrid_4.0.0')
e o erro que é mostrado é:
Started by user Cesar Sturion
[EnvInject] - Loading node environment variables.
Building in workspace C:\tools\Jenkins\jobs\python_test\workspace
[workspace] $ cmd /c call C:\Windows\TEMP\hudson8964393343238447186.bat
C:\tools\Jenkins\jobs\python_test\workspace>SET PATH=C:\tools\Java\jdk1.8.0_112\bin;C:\tools\apache-maven\maven-3.2.5\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\tools\nodejs\;C:\tools\Python27;
C:\tools\Jenkins\jobs\python_test\workspace>call python C:/tools/libs/directory.py
C:\tools\Jenkins\jobs\python_test\workspace>call python create_directory('c:/temp/versions', 'ingrid_4.0.0')
python: can't open file 'create_directory('c:/temp/versions',': [Errno 22] Invalid argument
C:\tools\Jenkins\jobs\python_test\workspace>exit 2
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Segue abaixo o arquivo python:
import os
from shutil import copyfile
def create_envFile(workspace):
global gworkspace
gworkspace = workspace
envfile = open(gworkspace + '/envfile.properties', 'w')
def write_envFile(parameter):
envfile = open(gworkspace + '/envfile.properties', 'a')
envfile.write(parameter + ' \n')
envfile.close
def version_name(branch):
name = branch.lower()
version_name = name.replace('rc_', '')
write_envFile('NOME_VERSAO=' + version_name)
def calcReleaseProduct(base, version_name):
if os.path.isfile(os.path.join(base, version_name)):
listDir = os.listdir(os.path.join(base, version_name))
try:
dir = listDir[-len(listDir)]
splitDir = dir.split('.')
nroRelease = int(splitDir[len(splitDir) - 1])
nroRelease += 1
release = version_name + '.' + ( "%02d" % (nroRelease,) )
except IndexError:
release = version_name + '.00'
else:
release = version_name + '.00'
return release
def calcReleaseProject(base, version_name):
import time
release = version_name + '_' + time.strftime("%Y%m%d_%H%M")
return release
def create_directory(base, version_name):
strSearch = 'muinga'
if (version_name.find(strSearch) >= 0):
release = calcReleaseProject(base, version_name)
else:
release = calcReleaseProduct(base, version_name)
os.makedirs(base + '/' + version_name + '/' + release)
def copyFile(src, dst):
copyfile(src, dst)
Desde já agradeço a ajuda.