Post

4 followers Follow
0
Avatar

Question: How can I invoke Jenkins Maven project jobs from XL Release?

Hi,

I have XL Release calling jobs in Jenkins. If the jobs are shell scripts (Jenkins Freestyle Jobs) then they work fine, however if the job is a maven project then XL Release fails with the following error.

Script failed:
Exception during execution:
TypeError: 'NoneType' object is unsubscriptable in <script> at line number 77

Martin Stevens

Please sign in to leave a comment.

14 comments

0
Avatar

Hi Martin, do you have a snippet of the XL Release log file of the time of the error? You can find the log file in log/xl-release.log in the XL Release installation directory.

Hes Siemelink 0 votes
0
Avatar
TypeError: 'NoneType' object is unsubscriptable in <script> at line number 77' on task 'Test User Journey'
2015-09-03 16:21:06.331 [qtp469117221-17] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Restarted Task 'Test User Journey'
2015-09-03 16:21:06.333 [qtp469117221-17] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Restarted Phase 'New Phase'
2015-09-03 16:21:06.333 [qtp469117221-17] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Restarted Release
2015-09-03 16:21:06.496 [qtp469117221-17] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Added a comment 'TRY 5' on task 'Test User Journey'
2015-09-03 16:21:07.157 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - Script output : 
2015-09-03 16:21:07.162 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} WARN  c.x.xlrelease.script.ScriptService - Exception during execution
javax.script.ScriptException: TypeError: 'NoneType' object is unsubscriptable in <script> at line number 77
    at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202) ~[jython-standalone-2.7.0.jar:na]
[...]
    ... 13 common frames omitted
2015-09-03 16:21:07.163 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - Exception during execution:

2015-09-03 16:21:07.163 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - TypeError: 'NoneType' object is unsubscriptable in <script> at line number 77
2015-09-03 16:21:07.214 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Task 'Test User Journey': 
2015-09-03 16:21:07.214 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Phase 'New Phase'
2015-09-03 16:21:07.215 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Release
2015-09-03 16:21:07.686 [pool-1-thread-6] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Added attachment: 'script_output.log' (text/plain) on task: 'Test User Journey'
2015-09-03 16:21:12.995 [pool-1-thread-17] {} INFO  c.x.xlrelease.domain.ReleaseActivity - Added a comment 'Exception during execution:
TypeError: 'NoneType' object is unsubscriptable in <script> at line number 77' on task 'Test User Journey'
2015-09-03 16:23:36.717 [qtp469117221-14] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Restarted Task 'Test User Journey'
2015-09-03 16:23:36.717 [qtp469117221-14] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Restarted Phase 'New Phase'
2015-09-03 16:23:36.718 [qtp469117221-14] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Restarted Release
2015-09-03 16:23:36.861 [qtp469117221-14] {username=martin.stevens, request=/tasks/Release2094041-Phase9044649-Task5464457/retry, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Added a comment 'Try 6' on task 'Test User Journey'
2015-09-03 16:23:37.539 [pool-1-thread-16] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - Script output : 
2015-09-03 16:23:37.542 [pool-1-thread-16] {task=Applications/Release2094041/Phase9044649/Task5464457} WARN  c.x.xlrelease.script.ScriptService - Exception during execution
javax.script.ScriptException: TypeError: 'NoneType' object is unsubscriptable in <script> at line number 77
    at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202) ~[jython-standalone-2.7.0.jar:na]
[...]
    ... 13 common frames omitted
2015-09-03 16:23:37.542 [pool-1-thread-16] {task=Applications/Release2094041/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - Exception during execution:
Martin Stevens 0 votes
0
Avatar

Can you put something in the Job Parameters section of the Jenkins task in XL Release and try again?

I think the Jenkins task has figured out it is dealing with a parameterized job, but can't get the parameters from the task.

Hes Siemelink 0 votes
0
Avatar

Ok, the Jenkins job that I am calling does not have "This build is parameterized" checked.

I've added a value of "1" into the xlrelease job and still see the same error.

We now have a different error

Exception during execution: KeyError: 'parameterDefinitions' in <script> at line number 77

Martin Stevens 0 votes
0
Avatar
...
{task=Applications/Release5264393/Phase9044649/Task5464457} WARN  c.x.xlrelease.script.ScriptService - Exception during execution
javax.script.ScriptException: KeyError: 'parameterDefinitions' in <script> at line number 77
        at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202) ~[jython-standalone-2.7.0.jar:na]
...
        at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
Caused by: org.python.core.PyException: null
        at org.python.core.Py.KeyError(Py.java:249) ~[jython-standalone-2.7.0.jar:na]
        at org.python.core.JavaProxyMap$11.__call__(JavaProxyMap.java:186) ~[jython-standalone-2.7.0.jar:na]
...
        ... 13 common frames omitted
2015-09-08 17:21:11.256 [pool-1-thread-11] {task=Applications/Release5264393/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - Exception during execution:

2015-09-08 17:21:11.256 [pool-1-thread-11] {task=Applications/Release5264393/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - KeyError: 'parameterDefinitions' in <script> at line number 77
2015-09-08 17:21:11.300 [pool-1-thread-11] {task=Applications/Release5264393/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Task 'Test User Journey':
2015-09-08 17:21:11.301 [pool-1-thread-11] {task=Applications/Release5264393/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Phase 'New Phase'
2015-09-08 17:21:11.301 [pool-1-thread-11] {task=Applications/Release5264393/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Release
2015-09-08 17:21:11.674 [pool-1-thread-11]
Martin Stevens 0 votes
0
Avatar

Tried in the xlrelease job parameter "a=1"

Gives the following in the logs

The job is not parametized.

It is a maven job. All other xlrelease -> shell jobs work fine. All jenkins maven jobs fail

We are using jenkins version 1.578.

We do use project based security, again this works fine on freestyle/shell jobs nut not maven ones.

2015-09-09 08:05:46.171 [qtp469117221-18] {username=martin.stevens, request=/releases/Release8816231/start, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Started Release
2015-09-09 08:05:46.172 [qtp469117221-18] {username=martin.stevens, request=/releases/Release8816231/start, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Started Phase 'New Phase'
2015-09-09 08:05:46.172 [qtp469117221-18] {username=martin.stevens, request=/releases/Release8816231/start, method=POST} INFO  c.x.xlrelease.domain.ReleaseActivity - Started Task 'Build Development'
2015-09-09 08:05:57.933 [pool-1-thread-15] {task=Applications/Release8816231/Phase9044649/Task2559480} INFO  c.x.xlrelease.script.ScriptService - Job '228_DEV_Check_CMS_Version' #21
2015-09-09 08:05:57.935 [pool-1-thread-15] {task=Applications/Release8816231/Phase9044649/Task2559480} INFO  c.x.xlrelease.script.ScriptService - Finished: SUCCESS
2015-09-09 08:05:57.936 [pool-1-thread-15] {task=Applications/Release8816231/Phase9044649/Task2559480} INFO  c.x.xlrelease.script.ScriptService - Script output : Job '228_DEV_Check_CMS_Version' #21
Finished: SUCCESS

2015-09-09 08:05:58.070 [pool-1-thread-15] {task=Applications/Release8816231/Phase9044649/Task2559480} INFO  c.x.xlrelease.domain.ReleaseActivity - Completed Task 'Build Development'
2015-09-09 08:05:58.070 [pool-1-thread-15] {task=Applications/Release8816231/Phase9044649/Task2559480} INFO  c.x.xlrelease.domain.ReleaseActivity - Started Task 'Test User Journey'
2015-09-09 08:05:58.457 [pool-1-thread-15] {task=Applications/Release8816231/Phase9044649/Task2559480} INFO  c.x.xlrelease.domain.ReleaseActivity - Added attachment: 'script_output.log' (text/plain) on task: 'Build Development'
2015-09-09 08:05:58.712 [pool-1-thread-2] {} INFO  c.x.xlrelease.domain.ReleaseActivity - Added a comment 'Job '228_DEV_Check_CMS_Version' #21
Finished: SUCCESS
' on task 'Build Development'
2015-09-09 08:05:59.341 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - Script output :
2015-09-09 08:05:59.345 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} WARN  c.x.xlrelease.script.ScriptService - Exception during execution
javax.script.ScriptException: KeyError: 'parameterDefinitions' in <script> at line number 77
        at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202) ~[jython-standalone-2.7.0.jar:na]
...
        at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
Caused by: org.python.core.PyException: null
        at org.python.core.Py.KeyError(Py.java:249) ~[jython-standalone-2.7.0.jar:na]
...
        ... 13 common frames omitted
2015-09-09 08:05:59.346 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - Exception during execution:

2015-09-09 08:05:59.347 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} INFO  c.x.xlrelease.script.ScriptService - KeyError: 'parameterDefinitions' in <script> at line number 77
2015-09-09 08:05:59.391 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Task 'Test User Journey':
2015-09-09 08:05:59.392 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Phase 'New Phase'
2015-09-09 08:05:59.392 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Failed Release
2015-09-09 08:05:59.771 [pool-1-thread-7] {task=Applications/Release8816231/Phase9044649/Task5464457} INFO  c.x.xlrelease.domain.ReleaseActivity - Added attachment: 'script_output.log' (text/plain) on task: 'Test User Journey'
2015-09-09 08:05:59.986 [pool-1-thread-25] {} INFO  c.x.xlrelease.domain.ReleaseActivity - Added a comment 'Exception during execution:
KeyError: 'parameterDefinitions' in <script> at line number 77' on task 'Test User Journey'
2015-09-09 08:06:16.296 [pool-1-thread-14] {} INFO  c.x.x.s.ArchivingScheduleService - Archiving 1 releases.
2015-09-09 08:06:17.204 [Finalizer] {} INFO  c.x.o.spi.BaseOverthereConnection - Disconnected from local:
2015-09-09 08:06:17.255 [Finalizer] {} INFO  c.x.o.spi.BaseOverthereConnection - Disconnected from local:
2015-09-09 08:06:17.292 [Finalizer] {} INFO  c.x.o.spi.BaseOverthereConnection - Disconnected from local:
2015-09-09 08:06:17.293 [Finalizer] {} INFO  c.x.o.spi.BaseOverthereConnection - Disconnected from local:
2015-09-09 08:06:17.336 [Finalizer] {} INFO  c.x.o.spi.BaseOverthereConnection - Disconnected from local:
2015-09-09 08:06:17.356 [Finalizer] {} INFO  c.x.o.spi.BaseOverthereConnection - Disconnected from local:
2015-09-09 08:06:18.246 [pool-1-thread-14] {} INFO  c.x.d.s.g.JackrabbitGarbageCollectionService - Garbage collector completed
Martin Stevens 0 votes
0
Avatar

Hi Martin

Thanks for posting this.

The job is not parametized.
It is a maven job. All other xlrelease -> shell jobs work fine. All jenkins maven jobs fail
We are using jenkins version 1.578.
We do use project based security, again this works fine on freestyle/shell jobs nut not maven ones.

I've tried to reproduce this, and unfortunately everything seems to work :-( I'm running a vanilla Jenkins 1.578 with Global Security enabled using matrix-based security, with a simple Maven job that is not parameterized. Calling this from a vanilla 4.7.1 XL Release (with no value in the "job parameters" property) installation works as expected:

Are you using a modified version of the task implementation script (probably in SERVER_HOME/ext)? Which permissions does the user have on the job that we're trying to run?

Regards

Andrew

Andrew Phillips 0 votes
0
Avatar

I can now force it to work with the following code changes...

We don't use any paramatized builds at the moment, so it shouldn't break anything else.

 76 # Commented out by MS - ExpertHealth 14/9/2015
 77 #if isJobParameterized(request, jobContext):
 78 #    buildContext = jobContext + 'buildWithParameters' + buildQueryString(jobParameters)
 79 #else:
 80 #    buildContext = jobContext + 'build'
 81 buildContext = jobContext + 'build'
Martin Stevens 0 votes
0
Avatar

Hi Martin

I can now force it to work with the following code changes...

Thanks for the update. I hope we'll find a way to reproduce this issue because it'd still be good to know what's actually going wrong here: whether isJobParameterized fails or whether it succeeds but incorrectly concludes the job is parameterized when it actually isn't.

In any case, glad to hear you were able to get things to work for now!

Regards

Andrew

Andrew Phillips 0 votes
0
Avatar

Hi Martin

whether isJobParameterized fails or whether it succeeds but incorrectly concludes the job is parameterized when it actually isn't

A quick follow-up question on that: does the isJobParameterized method in the version of Build.py that you've modified look like this?

def isJobParameterized(request, jobContext):
    jobInfo = request.get(jobContext + 'api/json', contentType = 'application/json')
    jobActions = JsonPathResult(jobInfo.response, 'actions').get()

    if jobActions is not None:
        for action in jobActions:
            if (action is not None and 'parameterDefinitions' in action):
                return True

    return False

If not, could you paste the version of isJobParameterized that you have into this thread?

Regards

Andrew

Andrew Phillips 0 votes