简体   繁体   中英

Restrict what jobs can run on Jenkins Slave, via SSH Creds in Pipeline

We have a global jenkins master, that many teams manage and use. We have our own jenkins slave, that we manage and as our own tools on it. I'd like to restrict the use of that slave, to only our jobs leveraging pipeline as code. The below is some sudo code of what I want to achieve. My question, is this possible or will this work?

 UserPass = getCredsFromCredStore
 withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable: 'USERPASS')]) {
     node ('myNode')  { //need to dynamically configure this
        //do Stuff
     }

}

The withCredentials will pass SSH credentials to the node inside the scope of running inside the block. Therefore, other team members, can only run jobs on this slave, if they know the ssh details, which we will manage in our external credentials store.

The only way to do what you want is with the Folders Plus plugin, which is a cloudbees plugin, and not free. You can restrict a slave to only be used by a specific folder of jobs.

You can't use code in a job to restrict the slave, because someone could just write other code in another job that doesn't have the same restrictions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM