ftpPublish declarative pipeline - node.js

I have the following pipeline:
pipeline {
agent any
stages {
... building stuff...
stage('push to develop'){
when {
branch 'develop'
}
steps {
ftpPublisher paramPublish: [ parameterName: "" ], alwaysPublishFromMaster: true, masterNodeName: master, continueOnError: false, failOnError: false, publishers: [
[configName: 'cp-front', usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true, transfers: [
[asciiMode: false, cleanRemote: false, excludes: '', flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/*']
]]
]
}
}
}
}
Unfortunately, this throws:
groovy.lang.MissingPropertyException: No such property: master for
class: groovy.lang.Binding at
groovy.lang.Binding.getVariable(Binding.java:63) at
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:264)
at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
at
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
at
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at
com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at
com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:22)
Which gives me about 0 idea what is going on. Any pointers?

master (an object, property) is not equal to 'master' - which is an instance of String. Maybe you made a simple mistake?

Related

RethinkDB pub/sub ReqlPermissionError

I'm using Publish-Subscribe with RethinkDB.
For exchange I use one db named 'RPI_messages' with three tables:
Connector_messages
MAC_messages
Orders
I want to introduce some basic authentication on producer and consumer sides like this:
r.db('rethinkdb').table('users').insert({id: 'lis', password: 'somepassword'})
r.db('rethinkdb').table('users').insert({id: 'rpi', password: 'someotherpassword'})
r.db('RPi_messages').grant('lis', {read: false, write: true, config: true}) //producer
r.db('RPi_messages').grant('rpi', {read: true, write: false, config: true}) //consumers
r.db('rethinkdb').table('permissions')
shows this:
{
"database": "RPi_messages" ,
"id": [
"lis" ,
"007928e5-c654-4311-b3aa-a834c62dcf88"
] ,
"permissions": {
"config": true ,
"read": false ,
"write": true
} ,
"user": "lis"
}
Problem:
When I try to publish or to subscribe to exchange it throws an exception:
ReqlPermissionError: User `lis` does not have the required `config` permission in:
r.db_create('RPi_messages')
rethinkdb.errors.ReqlPermissionError: User `rpi` does not have the required `config` permission in:
r.db_create('RPi_messages')
Does this mean that my users need to have global permissions?
Any help greatly appreciated.
So, with fairly bit of try and error I made it work.
For anyone else: You need config permission on global scope for every user in your pub-sub system like this:
r.grant('lis', {read: false, write: false, config: true});
r.grant('rpi', {read: false, write: false, config: true});
...and following permissions on table(s) or, in my case, on database scope:
r.db('RPi_messages').grant('lis', {read: true, write: true, config: true}); //publisher
r.db('RPi_messages').grant('rpi', {read: true, write: false, config: true}); //sunscriber
Correct me if I'm wrong but this doesn't look very secure to me. Those permissions are needed because Exchanger class in rethink's pub-sub system looks if exchange table exists and creates on if it doesn't. Which means that anyone who gets one of your client subscriber devices can create as many tables in your db as they want.

Gitlab checkout.groovy fails after upgrade to 12.1.17 from 12.0.1

In Jenkins i had an analysis job. The job used to checkout and build the merge request sent to the target branch. However, after upgrading the gitlab version from 12.0.1 to 12.1.17 i am unable to checkout source branch.
Below is the groovy script i was using.
#!/usr/bin/env groovy
def call() {
if (env.gitlabMergeRequestId) {
sh "echo '${env.gitlabMergeRequestId}'"
sh "echo 'Merge request detected. Merging...'"
def credentialsId = scm.userRemoteConfigs[0].credentialsId
checkout ([
$class: 'GitSCM',
branches: [[name: "${env.gitlabSourceNamespace}/${env.gitlabSourceBranch}"]],
extensions: [
[$class: 'PruneStaleBranch'],
[$class: 'CleanCheckout'],
[
$class: 'PreBuildMerge',
options: [
fastForwardMode: 'NO_FF',
mergeRemote: env.gitlabTargetNamespace,
mergeTarget: env.gitlabTargetBranch
]
]
],
userRemoteConfigs: [
[
credentialsId: credentialsId,
name: env.gitlabTargetNamespace,
url: env.gitlabTargetRepoHttpURL
],
[
credentialsId: credentialsId,
name: env.gitlabSourceNamespace,
url: env.gitlabSourceRepoHttpURL
]
]
])
} else {
sh "echo 'No merge request detected. Checking out current branch'"
checkout ([
$class: 'GitSCM',
branches: scm.branches,
extensions: [
[$class: 'PruneStaleBranch'],
[$class: 'CleanCheckout']
],
userRemoteConfigs: scm.userRemoteConfigs
])
}
}
I was able to solve it by adding in the branches
branches: [[name: "refs/heads/${env.gitlabSourceBranch}"]]

groovy:: compound if statement not evaluating to true

hi I am trying to understand issue where given if (version_exists != '' && env.force_build == true) is evaluating to true even if env.force_build is set to false
pipeline {
agent { label 'master' }
parameters {
string(defaultValue: 'DEV', description: '', name: 'ENV', trim: true)
string(defaultValue: 'sys', description: '', name: 'platform_type', trim: true)
string(defaultValue: 'yyy', description: '', name: 'dev_app_host', trim: true)
string(defaultValue: 'xxx.dv.local', description: '', name: 'dev_xbar_host', trim: true)
string(defaultValue: '1.0.0.23', description: '', name: 'VERSION', trim: true)
booleanParam(defaultValue: false, description: 'force build if possible', name: 'force_build')
}
environment {
git_credential_id = '1234'
app_name = 'application'
app_module_name = 'dvmt_event_processor'
app_git_url = 'ssh://git#oooo:7999/data/application.git'
dna_common_git_url = 'ssh://git#oooo:7999/data/dna-common.git'
ansible_git_url = 'ssh://git#oooo:7999/data/operations-ansible.git'
pip_port = '9700'
}
stages {
stage('checkout from SCM') {
.....
}
stage('build') {
steps {
script {
// version_exists == dvmt_event_processor-1.0.0.23-py2.py3-none-any.whl
// force_build == false
def version_exists = ''
version_exists = sh(script: "ssh -o StrictHostKeyChecking=no ansible#pypi server ls /var/pypi/packages/dev/ | grep ${env.app_module_name} | grep ${env.VERSION}" , returnStdout: true)
if (version_exists != '' && env.force_build == true) {
......
// evaluating to true no matter what
}
}
else if (version_exists != '' && env.force_build == false ) {
echo "version already exists, just deploying"
......
}
else {
echo "starting full build"
.........
}
}
}
}
stage('Test') {
steps {
echo 'Testing...'
.............
}
}
}
}
jenkins console o/p
dvmt_event_processor-1.0.0.23-py2.py3-none-any.whl
[Pipeline] echo
false
[Pipeline] echo
starting full build
env.force_build prints like a boolean, but it is a string.
"false" == true
// → false
"false" == false
// → false
Always debug problems like this with the proper tools. Use .inspect()
or even .dump() to get insights, what kind of data you have at hand:
"false".inspect()
// → 'false'
"false".dump()
// → <java.lang.String#5cb1923 value=[102, 97, 108, 115, 101] coder=0 hash=97196323>
Note the quotes around false with the .inspect() example.
To convert a string to boolean with groovy, you can use
String.toBoolean():
"false".toBoolean() == true
// → false
"false".toBoolean() == false
// → true

Python iterate over all possible combinations on boolean variables

I have 6 booleas variables in a dict and I want to run my code on all all their possible iteration.
so I have:
params["is_A"] = True/False
params["is_B"] = True/False
...
and then for all possible combinations, I want to call
my_func(params)
What is the best way to do so?
itertools.product can generate all the combinations:
import itertools
names = 'is_A is_B is_C is_D is_E is_F'.split()
def my_func(params):
print(params)
for p in itertools.product([True,False],repeat=6):
params = dict(zip(names,p))
my_func(params)
Output:
{'is_A': True, 'is_B': True, 'is_C': True, 'is_D': True, 'is_E': True, 'is_F': True}
{'is_A': True, 'is_B': True, 'is_C': True, 'is_D': True, 'is_E': True, 'is_F': False}
...
{'is_A': False, 'is_B': False, 'is_C': False, 'is_D': False, 'is_E': False, 'is_F': True}
{'is_A': False, 'is_B': False, 'is_C': False, 'is_D': False, 'is_E': False, 'is_F': False}

Blockly Example of Multiple Workspaces

I'm attempting to create a platform that allows students to play code challenges head-to-head using blockly. I'm imagining something like:
The documentation mentions "Multiple workspaces" with block factory, but I feel like I might be reinventing the wheel here, so before I get started, does something like this already exist? Ideally, hooked up to app engine so students could grab code from any other student and test to see how their code compares?
Yes, it exists! We use this in the Developer Tools to give both an editor and the preview. Two demos to look at are the Multi-Playground (src) and the Mirrored Workspaces (src).
You'll notice in the multi-playground, we just call Blockly.inject(..) on each div:
function start() {
// ...
startBlocklyInstance('VertStartLTR', false, false, 'start', toolbox);
startBlocklyInstance('VertStartRTL', true, false, 'start', toolbox);
startBlocklyInstance('VertEndLTR', false, false, 'end', toolbox);
startBlocklyInstance('VertEndRTL', true, false, 'end', toolbox);
startBlocklyInstance('HorizontalStartLTR', false, true, 'start', toolbox);
startBlocklyInstance('HorizontalStartRTL', true, true, 'start', toolbox);
startBlocklyInstance('HorizontalEndLTR', false, true, 'end', toolbox);
startBlocklyInstance('HorizontalEndRTL', true, true, 'end', toolbox);
}
function startBlocklyInstance(suffix, rtl, horizontalLayout, position,
toolbox) {
options.rtl = rtl;
options.toolbox = toolbox;
options.horizontalLayout = horizontalLayout;
options.toolboxPosition = position;
Blockly.inject('blocklyDiv' + suffix, options);
}

Resources