Jenkins 2.0 pipeline as code executor question

67 views
Skip to first unread message

Marslo Jiao

unread,
May 10, 2017, 7:52:06 AM5/10/17
to Jenkins Users

Is there anyway that I can manage the executor number for the same Jenkins job (using jenkins 2.0 pipeline as code)? All multiple builds in the same job will failed due to resource conflict.


Here is my situation:

  • In the slave configuration, the # of executors was set as 2:
    
  • But lots Jenkins job will be triggered on this node at the same time:
    


The Jenkinsfile is:

node ('ios') {
    stage
("Preparation") {
        sh
'''
        ... ...
        '''

   
}
    stage
("Preparation") {
        sh
'''
        ... ...
        '''

   
}
...
}

Thanks a lot.

Marslo Jiao

unread,
May 10, 2017, 8:03:01 AM5/10/17
to Jenkins Users
The Jenkinsfile is

node ('ios') {
    stage
("Preparation") {

       
       
// repo checkout

   
}
    stage
("Build") {
       
// npm install
       
// npm run my-command

   
}
...
}

Build Trigger is:



Cuong Tran

unread,
May 10, 2017, 1:10:59 PM5/10/17
to Jenkins Users
You should make your build commands work correctly when running inside the same node (avoid using locations outside of the workspace).

Marslo Jiao

unread,
May 10, 2017, 11:40:31 PM5/10/17
to Jenkins Users
What "avoid using locations outside of the workspace" means?

Björn Pedersen

unread,
May 11, 2017, 10:16:58 AM5/11/17
to Jenkins Users

Hi,

what kind of ressource conflict is happening? If some part of your build opens a tcp port, then conflicts may be resolved by using the
port allocator plugin.

Björn

Cuong Tran

unread,
May 11, 2017, 12:18:09 PM5/11/17
to Jenkins Users
Hi,

What I meant is to you should update your build script so it doesn't create files outside of the build workspace or anything that would prevent it to run concurrently. For example, this creates file inside your workspace and can run on multi-executor slave without any issue:

stage {
   sh 'rm -f hello.txt; date > hello.txt' # hello is inside workspace
   sh 'npm install foo'
}

where it would cause problems when you run it concurrently:

stage {
   sh 'rm -f /Users/devops/hello.txt; date > /Users/devops/hello.txt'
   sh 'npm install -g foo'

Marslo Jiao

unread,
May 12, 2017, 2:18:48 AM5/12/17
to Jenkins Users
Hi Björn,

This job is about to build an app based on iOS. During the app building. The conflict, for example is, there's a key need to be installed like:
security unlock-keychain -p <LOGIN_PWD> xxx.keychain
security
import <KEY_PATH.p12> -k xxx.keychain -t priv -f pkcs12 -A -P <LOGIN_PWD>

The key will be unlock once and import once. It will cause conflict when the older-build is building the package, and the newer-build unlock the key.

Marslo Jiao

unread,
May 12, 2017, 2:21:12 AM5/12/17
to Jenkins Users
Hi Cuong,

There's no any other files created outside of workspace.
I'm looking for the why the # of executor was set as 2, but multiple jobs running on this node.

I think it should be the issue of Jenkins.

Marslo Jiao

unread,
May 15, 2017, 6:53:12 AM5/15/17
to Jenkins Users
I think this is the Jenkins Slave issue. And create a issue at: https://issues.jenkins-ci.org/browse/JENKINS-44267
Reply all
Reply to author
Forward
0 new messages