问:
Jenkinsfile with globaly defined manager produce error if I pass manager instance outside of pipeline
I want to pass notifications in few slack channels.
Jenkinsfile:

```<code>def mng = manager

def notifyOnError(msg){
    def attachments = [
      [
        text: msg,
        color: '#ff0000'
      ]
    ]
    slackSend(channel: '#errors', attachments: attachments, tokenCredentialId: 'Slack')
    slackSend(channel: '#general', attachments: attachments, tokenCredentialId: 'Slack')
}

pipeline {
  agent any
  stages {
    stage('error') {
      steps {
        sh missed  // raise error
      }
    }
  }
  post {
    success {
      slackSend channel: '#general', color: 'good', message: "Build: <${env.BUILD_URL}|${env.JOB_NAME} Complete", tokenCredentialId: 'Slack'
    }
    unsuccessful {
      echo(mng.build.result.toString())
      notifyOnError("Build <${env.BUILD_URL}|${env.JOB_NAME} #${env.BUILD_NUMBER}> ${mng.build.result.toString()}")
    }
  }
}
</code>```

and I got this in pipeline.log:

```Push event to branch both
Connecting to https://api.github.com using im/****** (GitHub Access Token)
Obtained Jenkinsfile from f30010e52c041d3497229c8d746c348fc43b793a
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/ci-test_both
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
using credential github
 > git rev-parse --is-inside-work-tree # timeout=10
[Pipeline] echo
FAILURE
[Pipeline] slackSend
Slack Send Pipeline step running, values are - baseUrl: <empty>, teamDomain: agblox-workspace, channel: #errors, color: <empty>, botUser: false, tokenCredentialId: Slack
[Pipeline] }
Error when executing unsuccessful post condition:
java.io.NotSerializableException: org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
    at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)

    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
--------skipped due SO message size limit ------
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
    at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
    at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$0(RiverWriter.java:144)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:241)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:500)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:476)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:463)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:387)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: an exception which occurred:
    in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@7ca2827d
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@32344197
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@40455508
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@1487f4f1
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4f9801bc
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.TryBlockEnv@2c7bdf08
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@323cd55c
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@257775d6
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@278d4f1d
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4871dd10
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@38e48a82
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@33887dab
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@5b170b7c
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@c142ef
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@22ef2c5f
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@be0c435
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@21ce7eea
    in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
    in object com.cloudbees.groovy.cps.impl.CpsClosureDef@4676aaab
    in field com.cloudbees.groovy.cps.impl.CpsClosure.def
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@48b674b9
    in field groovy.lang.Closure.delegate
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@7908c9f3
    in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52

[Pipeline] }
[Pipeline] }
[Pipeline] End of Pipeline

GitHub has been notified of this commit’s build result

an exception which occurred:
    in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@7ca2827d
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@32344197
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@40455508
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@1487f4f1
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4f9801bc
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.TryBlockEnv@2c7bdf08
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@323cd55c
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@257775d6
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@278d4f1d
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4871dd10
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@38e48a82
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@33887dab
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@5b170b7c
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@c142ef
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@22ef2c5f
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@be0c435
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@21ce7eea
    in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
    in object com.cloudbees.groovy.cps.impl.CpsClosureDef@4676aaab
    in field com.cloudbees.groovy.cps.impl.CpsClosure.def
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@48b674b9
    in field groovy.lang.Closure.delegate
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@7908c9f3
    in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52
Caused: java.io.NotSerializableException: org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
    at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
    at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
    at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
    at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$0(RiverWriter.java:144)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:241)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:500)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:476)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:463)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:387)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
```

message been sent only to first channel and pipeline crashed. Without declaring def mng = manager all ok, but i want to pass build status. How  can I do it?

答:
Have encountered similar error. I have a variable to be used in whole stages of pipeline. Solved by moving the definition at the first stage:</p>

```<code>    ....
    stages {
    stage('error') {
      steps {
         script {
           mng = manager
           sh missed
        }
      }
    }
  }
  ...
</code>```

Body:
I want to pass notifications in few slack channels.
Jenkinsfile:

def mng = manager

def notifyOnError(msg){
    def attachments = [
      [
        text: msg,
        color: '#ff0000'
      ]
    ]
    slackSend(channel: '#errors', attachments: attachments, tokenCredentialId: 'Slack')
    slackSend(channel: '#general', attachments: attachments, tokenCredentialId: 'Slack')
}

pipeline {
  agent any
  stages {
    stage('error') {
      steps {
        sh missed  // raise error
      }
    }
  }
  post {
    success {
      slackSend channel: '#general', color: 'good', message: "Build: <${env.BUILD_URL}|${env.JOB_NAME} Complete", tokenCredentialId: 'Slack'
    }
    unsuccessful {
      echo(mng.build.result.toString())
      notifyOnError("Build <${env.BUILD_URL}|${env.JOB_NAME} #${env.BUILD_NUMBER}> ${mng.build.result.toString()}")
    }
  }
}

and I got this in pipeline.log:

Push event to branch both
Connecting to https://api.github.com using im/****** (GitHub Access Token)
Obtained Jenkinsfile from f30010e52c041d3497229c8d746c348fc43b793a
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/ci-test_both
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
using credential github
 > git rev-parse --is-inside-work-tree # timeout=10
[Pipeline] echo
FAILURE
[Pipeline] slackSend
Slack Send Pipeline step running, values are - baseUrl: <empty>, teamDomain: agblox-workspace, channel: #errors, color: <empty>, botUser: false, tokenCredentialId: Slack
[Pipeline] }
Error when executing unsuccessful post condition:
java.io.NotSerializableException: org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
    at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)

    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
--------skipped due SO message size limit ------
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
    at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
    at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$0(RiverWriter.java:144)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:241)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:500)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:476)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:463)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:387)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: an exception which occurred:
    in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@7ca2827d
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@32344197
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@40455508
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@1487f4f1
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4f9801bc
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.TryBlockEnv@2c7bdf08
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@323cd55c
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@257775d6
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@278d4f1d
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4871dd10
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@38e48a82
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@33887dab
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@5b170b7c
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@c142ef
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@22ef2c5f
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@be0c435
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@21ce7eea
    in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
    in object com.cloudbees.groovy.cps.impl.CpsClosureDef@4676aaab
    in field com.cloudbees.groovy.cps.impl.CpsClosure.def
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@48b674b9
    in field groovy.lang.Closure.delegate
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@7908c9f3
    in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52

[Pipeline] }
[Pipeline] }
[Pipeline] End of Pipeline

GitHub has been notified of this commit’s build result

an exception which occurred:
    in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@7ca2827d
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@32344197
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@40455508
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@1487f4f1
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4f9801bc
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.TryBlockEnv@2c7bdf08
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@323cd55c
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@257775d6
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@278d4f1d
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4871dd10
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@38e48a82
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@33887dab
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@5b170b7c
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@c142ef
    in field com.cloudbees.groovy.cps.impl.CallEnv.caller
    in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@22ef2c5f
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@be0c435
    in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
    in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@21ce7eea
    in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
    in object com.cloudbees.groovy.cps.impl.CpsClosureDef@4676aaab
    in field com.cloudbees.groovy.cps.impl.CpsClosure.def
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@48b674b9
    in field groovy.lang.Closure.delegate
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@7908c9f3
    in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@14606e52
Caused: java.io.NotSerializableException: org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
    at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
    at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
    at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
    at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
    at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
    at java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    at java.util.HashMap.writeObject(HashMap.java:1363)
    at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
    at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
    at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
    at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$0(RiverWriter.java:144)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:241)
    at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:500)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:476)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:463)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:387)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

message been sent only to first channel and pipeline crashed. Without declaring def mng = manager all ok, but i want to pass build status. How  can I do it?

Body:
Have encountered similar error. I have a variable to be used in whole stages of pipeline. Solved by moving the definition at the first stage:

    ....
    stages {
    stage('error') {
      steps {
         script {
           mng = manager
           sh missed
        }
      }
    }
  }
  ...


来源: stackexchange

问:
More than one form validation run statement
I want to get two form validation run statement in my project.First I want to check my select box value. If its space, then I am getting an error message. Here I also want to get a validation if the select box value is 'Other', Then I want to check the value in the text box. Is it possible.
Ie, I want to execute two form validation run statement.If first run statement is true, I have to check with the second run statement.</p>

答:
There is no reason you can't set some rules, run validation, then set some more rules and then run validation again.</p>

```<code>$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
if ($this->form_validation->run() == FALSE) {
    // Do whatever you do on fail
} else {
    $this->form_validation->set_rules('email', 'Email', 'required');
    if ($this->form_validation->run() == FALSE) {
        // do whatever you do on the 2nd fail
    }
    // do whatever you do on success
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
There is no reason you can't set some rules, run validation, then set some more rules and then run validation again.

$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
if ($this->form_validation->run() == FALSE) {
    // Do whatever you do on fail
} else {
    $this->form_validation->set_rules('email', 'Email', 'required');
    if ($this->form_validation->run() == FALSE) {
        // do whatever you do on the 2nd fail
    }
    // do whatever you do on success
}


问:
Angular 8, Angular Flex Layout: this._delegate.setClass is not a function
Updating to Angular 8, all my code that uses angular flex and has ngClass is broken:

```<code><div class="pages-container"
       [ngClass.lt-md]="{'mobile-no-padding': true}">
    <router-outlet></router-outlet>
  </div>
</code>```

returns an error upon rendering:
ERROR TypeError: this._delegate.setClass is not a function

Was only able to resolve this by removing the dynamic responsive suffix ([ngClass]="{'mobile-no-padding': true}) but that's a big stepback...

答:
Maybe if you reinstall your flex layout this'll get fixed

npm i @angular/flex-layout --save

ContentLicense: CC BY-SA 4.0

Body:
Updating to Angular 8, all my code that uses angular flex and has ngClass is broken:

    <router-outlet></router-outlet>

returns an error upon rendering:
ERROR TypeError: this._delegate.setClass is not a function

Was only able to resolve this by removing the dynamic responsive suffix ([ngClass]="{'mobile-no-padding': true}) but that's a big stepback...


问:
I'm trying to change the sandbox host used by the SSRS fetchdatasource
I'm not a CRM guy. I'm a SQL server / C# / general problem solver guy.

I'm trying to help one of our IT teams migrate to CRM 365. They are having issues with reports.

When I look at the report server log, I see that the relevant error seems to be:

Could not connect to net.tcp://<crmappserver>/CrmSandboxSdkListener-w3wp

We have four CRM application servers. Two of them have the "CRM sandbox listener", and two do not.  I don't know what the sandbox listener is or does, but that probably doesn't matter. What does matter is that the "crmappserver" in the URL is one of the two hosts without the sandbox listener installed. So, no surprise that it can't connect!

I relayed this information to the CRM team, but nobody in the team knows how to configure the fetch data source to use a particular host.

There's nothing in the data connector setup that allows me to enter that information: all I can enter is the SQL Server. So, I deduce that this information must be in the CRM configuration database somewhere, so I suggested that the team look through the administrative side of the CRM web user interface to see what they could find. But apparently the can find nowhere to configure this value.

How can we configure the CRM SSRS Fetch data source to point to host 3 instead of host 1 when it goes looking for the CRMSandboxSdkListener worker process?

Update from the CRM development team follows:

According to the CRM team, the report in question was originally created through the CRM application via the report wizard (probably in CRM 2011). As such, this report was always configured to use a fetch data source. The report works in CRM 2011, but the CRM 365 (on premise) platform is hosted on a different set of application servers.

In the CRM 365 installation the report is not pointing to one of the old 2011 hosts, which is good. Somehow during migration is has detected that the URL had to be updated from the old 2011 host to one of the four new 365 hosts. However, the problem remains that the 365 sandbox listener host referenced by the fetch data source is not one of the two hosts which is actually running that service.

答:
I believe you are currently on-Premise of Dynamics 365 (crm). You had your reports previously built with Sql data source (I believe).
Dynamics crm has changed the way Reports are been created in CRM. CRM does need FetchXMl as data source and not Sql.

Now you wish to change connection string/url so that it points to correct dynamics instance.

I would refer you to below link,This link shows how to create a SSRS report.
What is important in your case is Installing Microsoft dynamics 365 Reporting extension.Once you have this installed you would be have under Data source Type (Fetchxml) and then giving correct connection string will get you further.

Here is the Link:http://mastermindtechies.com/blogs/creating-ssrs-report-dynamics-365-online/


问:
Redux persistedState object is not setting default redux state
I have the following code:

```<code>    const persistedState = window.localStorage.getItem(DEFAULT_LOCALSTORAGE_NAME)
                              ? JSON.parse(window.localStorage.getItem(DEFAULT_LOCALSTORAGE_NAME))
                              : {};

    const store = createStore(rootReducer, persistedState, enhancer);

    console.log('persisted state', persistedState);
    console.log('stringified store', JSON.stringify(store.getState()));
</code>```

In the console however, I see the following result:

Any idea why the state is not correctly set (it uses the initial state that I set on my reducer)?

答:
I fixed the problem quite easily by refactoring the reducers: I applyed a flat structure and split up my current reducer using combinereducers.<br>
Reducers require pure functions without side effect, so actually it was more correct to do it this way anyhow.  </p>

Body:
I have the following code:

    const persistedState = window.localStorage.getItem(DEFAULT_LOCALSTORAGE_NAME)
                              ? JSON.parse(window.localStorage.getItem(DEFAULT_LOCALSTORAGE_NAME))
                              : {};

    const store = createStore(rootReducer, persistedState, enhancer);

    console.log('persisted state', persistedState);
    console.log('stringified store', JSON.stringify(store.getState()));

In the console however, I see the following result:

Any idea why the state is not correctly set (it uses the initial state that I set on my reducer)?

Body:
I fixed the problem quite easily by refactoring the reducers: I applyed a flat structure and split up my current reducer using combinereducers.

Reducers require pure functions without side effect, so actually it was more correct to do it this way anyhow.


问:
Bash: file not created with '>' command
I'm writing a script to create backups of a MySQL database running in a docker container. The database is correctly up and running.

My current code is

```<code>#!/bin/bash
PATH=/usr/bin:/usr/local/bin:/root/.local/bin:$PATH

docker-compose exec -T db mkdir -p /opt/booking-backup

docker_backup_path="/opt/booking-backup/dump_prod_$(date +%F_%R).sql"
copy_backup_path="/root/backup_scripts/booking_prod/dump_prod_$(date +%F_%R).sql"

docker-compose exec db mysqldump --add-drop-database --add-drop-table --user=root --password="pw" booking > "$docker_backup_path"
docker-compose exec db mysqldump --add-drop-database --add-drop-table --user=root --password="pw" booking > "/opt/booking-backup/dump_prod.sql"

[ -d ./backup ] || mkdir ./backup
docker cp $(docker-compose ps -q db):$docker_backup_path $copy_backup_path
</code>```

However, when I execute it it throws this error:

```<code>Error: No such container:path: f0baa241becd20d2690bb901fb257a4bbec8cac17e6f1ce6d50adb9532bbae03:/opt/booking-backup/dump_prod_2019-05-28_14:23.sql
</code>```

What makes this weirder is that I have the exact same code (but with booking switched out for abc, and with PSQL instead of MySQL) that works correctly.

It appears that this line

```<code>docker-compose exec db mysqldump --add-drop-database --add-drop-table --user=root --password="pw" booking > $docker_backup_path
</code>```

does not create the output file, but when I use tee I can see the contents of the dump and they are correct.

What's going wrong here?

答:
The shell redirections

```<code>docker-compose exec db mysqldump ... > "$docker_backup_path"
docker-compose exec db mysqldump ... > "/opt/booking-backup/dump_prod.sql"
# -----------------------------------^ here
</code>```

... will be expanded by your local shell, not inside the container. Meaning the files are written to your local filesystem not to the container's filesystem.

Title: Bash: file not created with '>' command

Body:
I'm writing a script to create backups of a MySQL database running in a docker container. The database is correctly up and running.

My current code is

#!/bin/bash
PATH=/usr/bin:/usr/local/bin:/root/.local/bin:$PATH

docker-compose exec -T db mkdir -p /opt/booking-backup

docker_backup_path="/opt/booking-backup/dump_prod_$(date +%F_%R).sql"
copy_backup_path="/root/backup_scripts/booking_prod/dump_prod_$(date +%F_%R).sql"

docker-compose exec db mysqldump --add-drop-database --add-drop-table --user=root --password="pw" booking > "$docker_backup_path"
docker-compose exec db mysqldump --add-drop-database --add-drop-table --user=root --password="pw" booking > "/opt/booking-backup/dump_prod.sql"

[ -d ./backup ] || mkdir ./backup
docker cp $(docker-compose ps -q db):$docker_backup_path $copy_backup_path

However, when I execute it it throws this error:

Error: No such container:path: f0baa241becd20d2690bb901fb257a4bbec8cac17e6f1ce6d50adb9532bbae03:/opt/booking-backup/dump_prod_2019-05-28_14:23.sql

What makes this weirder is that I have the exact same code (but with booking switched out for abc, and with PSQL instead of MySQL) that works correctly.

It appears that this line

docker-compose exec db mysqldump --add-drop-database --add-drop-table --user=root --password="pw" booking > $docker_backup_path

does not create the output file, but when I use tee I can see the contents of the dump and they are correct.

What's going wrong here?

Body:
The shell redirections

docker-compose exec db mysqldump ... > "$docker_backup_path"
docker-compose exec db mysqldump ... > "/opt/booking-backup/dump_prod.sql"
# -----------------------------------^ here

... will be expanded by your local shell, not inside the container. Meaning the files are written to your local filesystem not to the container's filesystem.


问:
Navigation Component: Passing bundles to destinations via Bottom Navigation
In my application I have a host fragment for a group of views that a user can navigate to via a BottomNavigationView. This BottomNavigationView is connected to my nav controller via setupWithNavController.

My host fragment receives a bundle with some information that I would like each fragment to receive as it is navigated to (via the bottom nav view) as a bundle.

My current solution looks like

```<code>        mutableListOf<NavDestination>().apply {
            addIfNotNull(graph.findNode(R.id.frag1))
            addIfNotNull(graph.findNode(R.id.frag2))
            addIfNotNull(graph.findNode(R.id.frag3))

            forEach {
                // args is a safe args object for this host fragment
                it.addArgument("argName", NavArgument.Builder().setDefaultValue(args.argName).build())
            }
        }
</code>```

While this works it will not scale very well as I am manually adding the arguments for each destination. Since I am not manually navigating to each destination, rather it is done by the BottomNavigationView I'm not sure how to manually add this bundle.

答:
```<code>navController.addOnDestinationChangedListener { controller, dest, args ->
            when (dest.label) {
                "YOUR_LABEL_HERE" -> {
                    val arg01 = NavArgument.Builder().setDefaultValue("SOME VALUE").build()
                    val arg02 = NavArgument.Builder().setDefaultValue("SOME OTHER VALUE").build()
                    dest.addArgument("KEY_NAME", arg01)
                    dest.addArgument("OTHER_KEY_NAME", arg02)
                }
            }
        }
</code>```

try this. It should work fine.

Body:
In my application I have a host fragment for a group of views that a user can navigate to via a BottomNavigationView. This BottomNavigationView is connected to my nav controller via setupWithNavController.

My host fragment receives a bundle with some information that I would like each fragment to receive as it is navigated to (via the bottom nav view) as a bundle.

My current solution looks like

        mutableListOf<NavDestination>().apply {
            addIfNotNull(graph.findNode(R.id.frag1))
            addIfNotNull(graph.findNode(R.id.frag2))
            addIfNotNull(graph.findNode(R.id.frag3))

            forEach {
                // args is a safe args object for this host fragment
                it.addArgument("argName", NavArgument.Builder().setDefaultValue(args.argName).build())
            }
        }

While this works it will not scale very well as I am manually adding the arguments for each destination. Since I am not manually navigating to each destination, rather it is done by the BottomNavigationView I'm not sure how to manually add this bundle.

Body:
navController.addOnDestinationChangedListener { controller, dest, args ->
            when (dest.label) {
                "YOUR_LABEL_HERE" -> {
                    val arg01 = NavArgument.Builder().setDefaultValue("SOME VALUE").build()
                    val arg02 = NavArgument.Builder().setDefaultValue("SOME OTHER VALUE").build()
                    dest.addArgument("KEY_NAME", arg01)
                    dest.addArgument("OTHER_KEY_NAME", arg02)
                }
            }
        }

try this. It should work fine.


问:
Write a function that returns the square of a number without using *,+ or pow
The task is to write a function that takes n as an input where n is a number (from -32768 to 32768) and returns the square of that number. Simple task except for the fact that we cannot use any operators such as *,+ or even use any Math. functions such as pow. eval is not allowed as well.
Even more challenging is that we must keep the character code count less than 39 characters.

I absolutely cannot think of a way to get the square of a number without using the + or *. And even worse, to keep the character count less, it's impossible for me.

Codes like this won't work because: I used the plus sign and the character count is more than 60.

```<code>function sq(n){
   var res=n;
   for(i=1;i<n;i++)
   res+=n;
return res;
}
</code>```

If n is a decimal, we are expected to return the nearest whole number as the result.
Thank you for reading all of this!

Edit: My problem has been solved. Thank you to everyone who has tried to help me with their codes as it helped me gain a new aspect of solving each problems.
Thank you very much again!

答:
You can try this as well

function multiply(a) {
  return a / (1 / a);
}

console.log(multiply(6))
console.log(multiply(4))```
</div>
</div>
</p>
<p><strong>The repeat() method returns a new string with a specified number of copies of the string it was called on.</strong> See here</p>
<p>This approach is limited to positive and integer numbers only.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// Another method

function multiplytwo(a) {
  return ("i").repeat(a).repeat(a).length
}

console.log(multiplytwo(4))
console.log(multiplytwo(25))

//creating a string “i” and repeating it “a” times, then repeats that “a” times, and then returning the length.</code>```

Body:
The task is to write a function that takes n as an input where n is a number (from -32768 to 32768) and returns the square of that number. Simple task except for the fact that we cannot use any operators such as *,+ or even use any Math. functions such as pow. eval is not allowed as well.
Even more challenging is that we must keep the character code count less than 39 characters.

I absolutely cannot think of a way to get the square of a number without using the + or *. And even worse, to keep the character count less, it's impossible for me.

Codes like this won't work because: I used the plus sign and the character count is more than 60.

function sq(n){
   var res=n;
   for(i=1;i<n;i++)
   res+=n;
return res;
}

If n is a decimal, we are expected to return the nearest whole number as the result.
Thank you for reading all of this!

Edit: My problem has been solved. Thank you to everyone who has tried to help me with their codes as it helped me gain a new aspect of solving each problems.
Thank you very much again!

Body:
You can try this as well

function multiply(a) {
  return a / (1 / a);
}

console.log(multiply(6))
console.log(multiply(4))

The repeat() method returns a new string with a specified number of copies of the string it was called on. See here

This approach is limited to positive and integer numbers only.

// Another method

function multiplytwo(a) {
  return ("i").repeat(a).repeat(a).length
}

console.log(multiplytwo(4))
console.log(multiplytwo(25))

//creating a string “i” and repeating it “a” times, then repeats that “a” times, and then returning the length.


问:
Javascript - getting TypeError is not iterable for an array
I am using react and I have a component where I am setting a constant with an array of strings:

```<code>const propsToCheck = ['text', 'type', 'status', 'topic.name', 'class.0.code'];
</code>```

I am sending down the children chain all the way to the component that is using it like this in the function checkObjectContainsValue that I import from another file:

```<code>constructor(props) {
    super(props);
    this.state.data = this.transformRows(props.rows.filter(obj => checkObjectContainsValue(obj, props.searchString)(props.propsToCheck)))
  }
</code>```

My tests are failing then because I get an error:

TypeError: propsToCheck is not iterable

But, I noticed that if I import the checkObjectContainsValue function to a parent component where I have propsToCheck I don't get the error. But I can't have that function there for other reasons. I have checked the react developer tools and I can see that I am getting the array propsToCheck in the child component, so I am not sure why I am getting this error?

This is the function checkObjectContainsValue:

```<code>const checkObjectContainsValue = (obj, value) => (propsToCheck) => {
  for (let prop of propsToCheck) {
    const propToCheckValue = prop.split('.').reduce((currentObject,property) => {
      return currentObject[property];
    }, obj);
    if (propToCheckValue.toLowerCase().includes(value.toLowerCase())) {
      return true;
    }
  }
  return false;
};
</code>```

Update

If I move the logic to a parent component then everything works fine. This is the example:

```<code>onSearchChange(event) {
    const searchString = event.target.value;
    this.setState(prevState => {
      const filteredTasks = prevState.tasks.filter(obj => checkObjectContainsValue(obj, searchString)(propsToCheck));
      return {filteredTasks: filteredTasks};
    });
  }
</code>```

Why am I getting this error only when I use this function in the child component?

答:
Your function expects three argument

```<code>const checkObjectContainsValue = (obj, value, propsToCheck) => {
</code>```

where as you're just passing two argument to function

```<code>props.rows.filter(obj => checkObjectContainsValue(obj, props.searchString)
</code>```

so the third argument will have a value equal to undefined which is not iterable

Body:
I am using react and I have a component where I am setting a constant with an array of strings:

const propsToCheck = ['text', 'type', 'status', 'topic.name', 'class.0.code'];

I am sending down the children chain all the way to the component that is using it like this in the function checkObjectContainsValue that I import from another file:

constructor(props) {
    super(props);
    this.state.data = this.transformRows(props.rows.filter(obj => checkObjectContainsValue(obj, props.searchString)(props.propsToCheck)))
  }

My tests are failing then because I get an error:

TypeError: propsToCheck is not iterable

But, I noticed that if I import the checkObjectContainsValue function to a parent component where I have propsToCheck I don't get the error. But I can't have that function there for other reasons. I have checked the react developer tools and I can see that I am getting the array propsToCheck in the child component, so I am not sure why I am getting this error?

This is the function checkObjectContainsValue:

const checkObjectContainsValue = (obj, value) => (propsToCheck) => {
  for (let prop of propsToCheck) {
    const propToCheckValue = prop.split('.').reduce((currentObject,property) => {
      return currentObject[property];
    }, obj);
    if (propToCheckValue.toLowerCase().includes(value.toLowerCase())) {
      return true;
    }
  }
  return false;
};

Update

If I move the logic to a parent component then everything works fine. This is the example:

onSearchChange(event) {
    const searchString = event.target.value;
    this.setState(prevState => {
      const filteredTasks = prevState.tasks.filter(obj => checkObjectContainsValue(obj, searchString)(propsToCheck));
      return {filteredTasks: filteredTasks};
    });
  }

Why am I getting this error only when I use this function in the child component?

Body:
Your function expects three argument

const checkObjectContainsValue = (obj, value, propsToCheck) => {

where as you're just passing two argument to function

props.rows.filter(obj => checkObjectContainsValue(obj, props.searchString)

so the third argument will have a value equal to undefined which is not iterable


问:
Run time Data Form!
i have a table which contains details of the form contents , here are the details

InputType ( value = Text / Radio / CheckBox , .... )

IsRequired ( True/False)

OrderedAnswers ( contain options available for Radio / checkbox  )

....

what i want is ,

make a page at run time which contains respective controls and the page submits the values of each control to the service .

at this point i have created the dataform , but cant define datatemplate dynamically so that i could add stackpanel to it and in the stackpanel i shall add the controls(based on the value). can you provide some code which shall create datatemplate dynamically and items to it ?

thanks

Jamal.

答:
I presume you want to add the stackpanel with controls to a particular property (in ria with a Silverlight DataForm)

first capture the event AutoGeneratingFieldi.e.

```<code>this.myDataForm.AutoGeneratingField +=new EventHandler<DataFormAutoGeneratingFieldEventArgs>(AutoGeneratingFieldHandler);
</code>```

then in the event handler

```<code>void AutoGeneratingFieldHandler(object sender, DataFormAutoGeneratingFieldEventArgs e)
{
  if(e.PropertyName=="myPropertyNameWithCustomField")
  {
     StackPanel pnl = new StackPanel();
     pnl.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
     ComboBox cbo = new ComboBox();
     //setup binding to base
     Binding b = new Binding("myPropertyNameWithCustomField") { Mode = BindingMode.TwoWay };
     cbo.SetBinding(ComboBox.SelectedValueProperty, b);
     //add the combo to the stackpanel
     pnl.Children.Add(cbo);
     //replace the autogenerated content with the stackpanel
     e.Field.Content=pnl;
     e.Field.IsRequired=true;
  }
}
</code>```

This should get you started setting up a DataForm with custom controls.

ContentLicense: CC BY-SA 2.5

Title: Run time Data Form!

Body:
I presume you want to add the stackpanel with controls to a particular property (in ria with a Silverlight DataForm)

first capture the event AutoGeneratingFieldi.e.

this.myDataForm.AutoGeneratingField +=new EventHandler<DataFormAutoGeneratingFieldEventArgs>(AutoGeneratingFieldHandler);

then in the event handler

void AutoGeneratingFieldHandler(object sender, DataFormAutoGeneratingFieldEventArgs e)
{
  if(e.PropertyName=="myPropertyNameWithCustomField")
  {
     StackPanel pnl = new StackPanel();
     pnl.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
     ComboBox cbo = new ComboBox();
     //setup binding to base
     Binding b = new Binding("myPropertyNameWithCustomField") { Mode = BindingMode.TwoWay };
     cbo.SetBinding(ComboBox.SelectedValueProperty, b);
     //add the combo to the stackpanel
     pnl.Children.Add(cbo);
     //replace the autogenerated content with the stackpanel
     e.Field.Content=pnl;
     e.Field.IsRequired=true;
  }
}

This should get you started setting up a DataForm with custom controls.


问:
Transmitting hex code through Arduino Leonardo by USART to device
I am trying to send a hex command to a device with an Arduino Leonardo, that also accepts commands through a Bluetooth interface.

Basically I am trying to switch a laser on and off through hex commands transmitted on an Arduino Leonardo, but I am having no luck. If I send the hex codes through the Bluetooth USB interface it works in the current configurationwiring config, but not when I try and push it over the TX pin (I had to use a voltage divider with a 5k6 and 12k Ohm to bring the voltage down from 5V to 3.3V).

The code I am trying is shown below:

```<code>byte laserON[] = {0xAA,0x00, 0x01, 0xBE, 0x00, 0x01, 0x00, 0x01, 0xC1};
byte laserOFF[] = {0xAA,0x00, 0x01, 0xBE, 0x00, 0x01, 0x00, 0x00, 0xC0};

void setup() {
 Serial1.begin(19200);
}

void loop() {
for(byte i =0;isizeof(laserON);i++)(Serial1.write(laserON[i]));

delay(1000);
Serial1.write(laserON, sizeof(laserON));

for(byte i =0;isizeof(laserOFF);i++)(Serial1.write(laserOFF[i]));
delay(1000);
Serial1.write(laserOFF, sizeof(laserOFF));
}
</code>```

答:
;isizeof(laserON); isn't any normal C code that I know. You could try and replace it with i < sizeof(laserON), this at least will fix your loop.

Serial.write(buf, len) is indeed better and you'll probably want to write Serial.write(&laserON[0], sizeof(laserON))

If you want to confirm that the bytes are sent correctly: use a scope or another uart adapter to read back the data you send and confirm if the bytes are the bytes you send. If there are any problems with that then: please update your post.

The Arduino Leonardo doesn't have more than one UART. Your problem with not seeing anything when directly connecting to pin 1 is:

On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication
  with the computer. Connecting anything to these pins can interfere
  with that communication, including causing failed uploads to the
  board.

The same probably goes for the Leonardo as it fairly similar. You'll have to use another Arduino board or a software UART if you want to communicate with another device. Another options is to use the double SPI or single I2C bus with a UART expander chip such a the MAX14830.

No idea why Serial1 compiles on your platform, maybe your board settings where wrong in the Arduino IDE and the chip is similar enough for it to compile/flash/work. As a debugging measure you could comment out the Serial sections and test it and then reverse it by uncommenting Serial and commenting Serial1.

Body:
I am trying to send a hex command to a device with an Arduino Leonardo, that also accepts commands through a Bluetooth interface.

Basically I am trying to switch a laser on and off through hex commands transmitted on an Arduino Leonardo, but I am having no luck. If I send the hex codes through the Bluetooth USB interface it works in the current configurationwiring config, but not when I try and push it over the TX pin (I had to use a voltage divider with a 5k6 and 12k Ohm to bring the voltage down from 5V to 3.3V).

The code I am trying is shown below:

byte laserON[] = {0xAA,0x00, 0x01, 0xBE, 0x00, 0x01, 0x00, 0x01, 0xC1};
byte laserOFF[] = {0xAA,0x00, 0x01, 0xBE, 0x00, 0x01, 0x00, 0x00, 0xC0};

void setup() {
 Serial1.begin(19200);
}

void loop() {
for(byte i =0;isizeof(laserON);i++)(Serial1.write(laserON[i]));

delay(1000);
Serial1.write(laserON, sizeof(laserON));

for(byte i =0;isizeof(laserOFF);i++)(Serial1.write(laserOFF[i]));
delay(1000);
Serial1.write(laserOFF, sizeof(laserOFF));
}


问:
output logs into /var/log/syslog
Our legacy system was outputting to /var/log/syslog with posix module without any tuning. But this posix package is no longer available in Node.js v10, we had to adopt other logging module.

We are now trying to use winston module instead of it, and our setting is like below.

```<code>this.logger = winston.createLogger({
  levels: winston.config.syslog.levels,
  transports: [
    new winston.transports.Console(),
    new winston.transports.File({
      filename: '/var/log/syslog'
    })
  ]
});
</code>```

But we can't get any logs in /var/log/syslog, maybe it is due to the permission problem.
Does anyone have the best solution for this?
What we would like to do is to enable to output logs into /var/log/syslog with ease settings.

I think the best way is to change destination file, if you don't have any better way, just tell 'change the destination file' to me.

答: Actually you can output log to console and redirect stdout and stderr streams to files </p>

Title: output logs into /var/log/syslog

Body:
Our legacy system was outputting to /var/log/syslog with posix module without any tuning. But this posix package is no longer available in Node.js v10, we had to adopt other logging module.

We are now trying to use winston module instead of it, and our setting is like below.

this.logger = winston.createLogger({
  levels: winston.config.syslog.levels,
  transports: [
    new winston.transports.Console(),
    new winston.transports.File({
      filename: '/var/log/syslog'
    })
  ]
});

But we can't get any logs in /var/log/syslog, maybe it is due to the permission problem.
Does anyone have the best solution for this?
What we would like to do is to enable to output logs into /var/log/syslog with ease settings.

I think the best way is to change destination file, if you don't have any better way, just tell 'change the destination file' to me.


问:
Passing Image from python wrapper to a c++ function
I want to pass a image from a python code to a c++ function. My c++ function is in a .so file and is being loaded to python using ctypes. The c++ function takes argument of type Mat. The argument (i.e. the image) is passed from Python (using opencv).

When i try to run the above scenario, it throws error as below;

ctypes.ArgumentError: argument 1: : Don't know how to convert parameter 1

My code is given below:
test.py

```<code>import cv2
from ctypes import *

testso = CDLL("./libvideoread.so")
cap = cv2.VideoCapture("Bigbunny.mp4")
if(cap.isOpened == False):
    print("error")
else:
    frame_width = int(cap.get(3))
    frame_height = int(cap.get(4))
    cv2.namedWindow('frame',cv2.WINDOW_NORMAL)
    while(cap.isOpened):
       ret,frame = cap.read()
       if ret:
          testso.imgread(frame)
       else:
           break

cap.release()
cv2.destroyAllWindows()
</code>```

cpp code:

```<code>void imgread(Mat frame)
{
     /*Do something*/
}
</code>```

Checked for the error online and came to know that Opencv-python converts image data to numpy array. And Opencv-c++ uses Mat type. So how can I convert numpy array to Mat type or Pass Image from python to c++ function.

I do not want to use Boost::python

Thanks.

答:
I finally figured out the solution to the problem.

I had to convert the mat format to a numpy array. and pass this array as argument to the cpp function imgread().

The cpp function imgread() needs to receive it as a char pointer and then convert it to mat.

Modified test.py;

```<code>import cv2
from ctypes import *

testso = CDLL("./libvideoread.so")
cap = cv2.VideoCapture("Bigbunny.mp4")
if(cap.isOpened == False):
    print("error")
else:
    frame_width = int(cap.get(3)) # Width is 1280
    frame_height = int(cap.get(4)) # Height is 720
    cv2.namedWindow('frame',cv2.WINDOW_NORMAL)
while(cap.isOpened):
   ret,frame = cap.read()
   if ret:
      # Next 3 lines convert frame data to numpy array
      testarray1 = np.fromstring(frame, np.uint8)
      testarray2 = np.reshape(testarray1, (720, 1280, 3))
      framearray = testarray2.tostring()

      #Send framearray to the cpp function.
      testso.imgread(framearray)
   else:
       break

 cap.release()
 cv2.destroyAllWindows()
</code>```

At cpp side;

```<code>void imgread(unsigned char* framedata)
{
  cv::Mat frame(cv::Size(1280,720), CV_8UC3, framedata);
   /*Do something*/
}
</code>```

Cheers.

Body:
I want to pass a image from a python code to a c++ function. My c++ function is in a .so file and is being loaded to python using ctypes. The c++ function takes argument of type Mat. The argument (i.e. the image) is passed from Python (using opencv).

When i try to run the above scenario, it throws error as below;

ctypes.ArgumentError: argument 1: : Don't know how to convert parameter 1

My code is given below:
test.py

import cv2
from ctypes import *

testso = CDLL("./libvideoread.so")
cap = cv2.VideoCapture("Bigbunny.mp4")
if(cap.isOpened == False):
    print("error")
else:
    frame_width = int(cap.get(3))
    frame_height = int(cap.get(4))
    cv2.namedWindow('frame',cv2.WINDOW_NORMAL)
    while(cap.isOpened):
       ret,frame = cap.read()
       if ret:
          testso.imgread(frame)
       else:
           break

cap.release()
cv2.destroyAllWindows()

cpp code:

void imgread(Mat frame)
{
     /*Do something*/
}

Checked for the error online and came to know that Opencv-python converts image data to numpy array. And Opencv-c++ uses Mat type. So how can I convert numpy array to Mat type or Pass Image from python to c++ function.

I do not want to use Boost::python

Thanks.

Body:
I finally figured out the solution to the problem.

I had to convert the mat format to a numpy array. and pass this array as argument to the cpp function imgread().

The cpp function imgread() needs to receive it as a char pointer and then convert it to mat.

Modified test.py;

import cv2
from ctypes import *

testso = CDLL("./libvideoread.so")
cap = cv2.VideoCapture("Bigbunny.mp4")
if(cap.isOpened == False):
    print("error")
else:
    frame_width = int(cap.get(3)) # Width is 1280
    frame_height = int(cap.get(4)) # Height is 720
    cv2.namedWindow('frame',cv2.WINDOW_NORMAL)
while(cap.isOpened):
   ret,frame = cap.read()
   if ret:
      # Next 3 lines convert frame data to numpy array
      testarray1 = np.fromstring(frame, np.uint8)
      testarray2 = np.reshape(testarray1, (720, 1280, 3))
      framearray = testarray2.tostring()

      #Send framearray to the cpp function.
      testso.imgread(framearray)
   else:
       break

 cap.release()
 cv2.destroyAllWindows()

At cpp side;

void imgread(unsigned char* framedata)
{
  cv::Mat frame(cv::Size(1280,720), CV_8UC3, framedata);
   /*Do something*/
}

Cheers.


问:
How to pass "a pointer to a function with parameters" to another function
I have the following system function:

```<code>int sock_yield( void *s, void (*fn)() );
</code>```

to which I need to pass a function that takes 2 parameters:

```<code>void reset(char buf,udp_Socket sock) {

    if (-1 == udp_recv(&sock, &buf, sizeof(buf)));

    if(buf=='R')
    {

        printf("\nReceived-> %c",buf);

        forceSoftReset();

        forceWatchdogTimeout();

    }

}
</code>```

When calling sock_yield function I can only pass it the name of the function without its parameter:
sock_yield(sock, reset)

How to specify the parameters of reset to be passed to sock_yield?

答:
You cannot do this. Converting between different function types is strictly speaking undefined behavior, although some compilers have non-standard extensions that allow it at some extent.

In addition, void (*fn)() means a function taking any parameters, which is obsolete style C and shouldn't be used.

So the sock_yield function must be rewritten. If it was meant to take a callback function as parameter, it was badly written from the start. It should take function pointers of one specific, specified format. For example:

```<code>typedef void sock_callback_t (char buf, udp_socket* sock);

int sock_yield(void* s, sock_callback_t* fn);
</code>```

Alterntatively you could write some hack where you convert between function pointers and uintptr_t, but it is a worse solution that should only be used if you are stuck with a badly written API.

Body:
I have the following system function:

int sock_yield( void *s, void (*fn)() );

to which I need to pass a function that takes 2 parameters:

void reset(char buf,udp_Socket sock) {

    if (-1 == udp_recv(&sock, &buf, sizeof(buf)));

    if(buf=='R')
    {

        printf("\nReceived-> %c",buf);

        forceSoftReset();

        forceWatchdogTimeout();

    }

}

When calling sock_yield function I can only pass it the name of the function without its parameter:
sock_yield(sock, reset)

How to specify the parameters of reset to be passed to sock_yield?

Body:
You cannot do this. Converting between different function types is strictly speaking undefined behavior, although some compilers have non-standard extensions that allow it at some extent.

In addition, void (*fn)() means a function taking any parameters, which is obsolete style C and shouldn't be used.

So the sock_yield function must be rewritten. If it was meant to take a callback function as parameter, it was badly written from the start. It should take function pointers of one specific, specified format. For example:

typedef void sock_callback_t (char buf, udp_socket* sock);

int sock_yield(void* s, sock_callback_t* fn);

Alterntatively you could write some hack where you convert between function pointers and uintptr_t, but it is a worse solution that should only be used if you are stuck with a badly written API.


问:
How to style a PrimeNG Chips?
I have a form in my application where I use the following code from Primafaces:

```<code>...other inputs...

<label for="workshopTags">Tags</label>
<p-chips
    [(ngModel)]="values"
    name="workshopTags"
    id="workshopTags"
></p-chips>
</code>```

I am able to display the Chip element correctly but I would like to style it putting its width to 100% and the height to 100px, but nothing seems to work to change those. This solution didn't work for me. I tried to set a styleClass or an inline style as the documentation suggest but they didn't work either. If I write inline:

```<code>style="width: 100%"
</code>```

The following error is thrown:

Error: Cannot find a differ supporting object 'width: 100%;'

How can I make it work?

答:
You could try encapsulation: ViewEncapsulation.None in your override component decorator:</p>

```<code>@Component({
   selector: 'app-chip',
   templateUrl: 'path-to-template where you use ui-chips',
   styleUrls: ['path-to-styles where you could override ui-chips styles'],
   encapsulation: ViewEncapsulation.None
})
export class AppChipComponent { }
</code>```

Title: How to style a PrimeNG Chips?

Body:
I have a form in my application where I use the following code from Primafaces:

...other inputs...

Tags

I am able to display the Chip element correctly but I would like to style it putting its width to 100% and the height to 100px, but nothing seems to work to change those. This solution didn't work for me. I tried to set a styleClass or an inline style as the documentation suggest but they didn't work either. If I write inline:

style="width: 100%"

The following error is thrown:

Error: Cannot find a differ supporting object 'width: 100%;'

How can I make it work?

Body:
You could try encapsulation: ViewEncapsulation.None in your override component decorator:

@Component({
   selector: 'app-chip',
   templateUrl: 'path-to-template where you use ui-chips',
   styleUrls: ['path-to-styles where you could override ui-chips styles'],
   encapsulation: ViewEncapsulation.None
})
export class AppChipComponent { }


答:
You can use ht /deep/ modifier ,add this inside your app.component.css and delete it from your style.css, and you don't need !important to force the style here, delete it. here is what you are looking for

```<code>p {
  font-family: Lato;
}

/deep/  .p-chips > .ui-inputtext {
  width: 100%;
  height:  100px;
}
</code>```

check it here https://stackblitz.com/edit/angular-primeng-startup-kmm7xw

Title: How to style a PrimeNG Chips?

Body:
You can use ht /deep/ modifier ,add this inside your app.component.css and delete it from your style.css, and you don't need !important to force the style here, delete it. here is what you are looking for

p {
  font-family: Lato;
}

/deep/  .p-chips > .ui-inputtext {
  width: 100%;
  height:  100px;
}

check it here https://stackblitz.com/edit/angular-primeng-startup-kmm7xw


答:
You most probably have indeed a permission problem considering /var/log/syslog is managed by system utilities.

Anyway the fastest solution is to use the npm package winston-syslog, it is pretty easy to configure if you look at the documentation

```<code>const winston = require('winston');

//
// Requiring `winston-syslog` will expose
// `winston.transports.Syslog`
//
require('winston-syslog').Syslog;

winston.add(new winston.transports.Syslog(options));
</code>```

Title: output logs into /var/log/syslog

Body:
You most probably have indeed a permission problem considering /var/log/syslog is managed by system utilities.

Anyway the fastest solution is to use the npm package winston-syslog, it is pretty easy to configure if you look at the documentation

const winston = require('winston');

//
// Requiring `winston-syslog` will expose
// `winston.transports.Syslog`
//
require('winston-syslog').Syslog;

winston.add(new winston.transports.Syslog(options));


问:
dplyr error - could not find function "%>%"
I am trying to run a line of code in R using the dplyr package.  dplyr is installed and the package appears to have loaded correctly, but does not recognise the %>% function.
The code I am attempting to run is -

```<code>reptiledata2 = reptiledata %>% filter (START_YEAR>=1980)
</code>```

This leads to the error:

```<code>Error in reptiledata %>% filter(START_YEAR >= 1980) :    could not find function "%>%"
</code>```

This code has previously worked for me before, but for some reason is not working today. Have also tried to load magrittr package but this does not solve the issue either.

答:
Install or reinstall dplyr package.
install.packages("dplyr")

If does not work, try to remove it and reinstall.

OwnerDisplayName: sjm

Body:
I am trying to run a line of code in R using the dplyr package.  dplyr is installed and the package appears to have loaded correctly, but does not recognise the %>% function.
The code I am attempting to run is -

reptiledata2 = reptiledata %>% filter (START_YEAR>=1980)

This leads to the error:

Error in reptiledata %>% filter(START_YEAR >= 1980) :    could not find function "%>%"

This code has previously worked for me before, but for some reason is not working today. Have also tried to load magrittr package but this does not solve the issue either.


问:
OAuth2 with Azure Active Directory without specifying the resource
I'm trying to obtain Auth Token using following tutorial:
https://learn.microsoft.com/en-us/azure/active-directory/active-directory-protocols-oauth-code

The important thing is that I'm not providing the "Resource" parameter. According to the documentation it's optional.

I am able to obtain the Authorization Code, but when I try to use it to get the Access Token I'm getting:

AADSTS50001: Resource identifier is not provided

According to the documentation Resource param should only be required if it was specified in the request for Auth Code. With Resource param it works fine, but I need to implement it without it.

答:
Make sure you have registered the application redirect uri in Azure AD. The redirect uri on the request needs to match the one registered on the identityprovider.

Request: authorize?client_id=<id>&scope=<scope>&response_type=id_token token&redirect_uri=<uri>


问:
How to create a lookup relationship between two custom objects using soql
I want to create lookup relationship between two custom object project and todo object but not  able to do so

This is the code to create lookup relationship between two object. It contain class two methods for create project and the create task respectively

```<code>public class ProjectAssignment { *//class ProjectAssignment*

     public static void createProject(){ *//method to create an object*
         Project__c pr=new Project__c();
         pr.Name='IseeIt'; //name of project
         pr.Start_Date__c= date.today()`
         pr.Description__c='This Is To Do Kind Project';
         pr.End_Date__c=date.today()+5;
         insert pr;
    }

    public static void createTask(){ *//create todo method
         //Code to fetch data*
        Project__c pr = [Select Id from Project__c]; *//query for lookup relationship between project and todo*
         ToDo__c td = new ToDo__c();
         td.Project__c= pr.Id; *//fetchhing project id*
         td.Start_Date__c=date.today();
         td.Description__c='This is the first task';
         td.End_Date__c=date.today()+2;
         insert td;

    }

}
</code>```

"System.QueryException: List has more than 1 row for assignment to SObject"
  because their are two project i have created  in the project object

答:
Try this.    </p>

```<code>Project__c pr = [Select Id from Project__c];
    For this, you have to Select the query in where clause and put LIMIt 1 so that they give you only one record.
    Project__c pr = [Select Id from Project__c where name = 'IseeIt' LIMIT 1];
</code>```

Body:
I want to create lookup relationship between two custom object project and todo object but not  able to do so

This is the code to create lookup relationship between two object. It contain class two methods for create project and the create task respectively

public class ProjectAssignment { *//class ProjectAssignment*

     public static void createProject(){ *//method to create an object*
         Project__c pr=new Project__c();
         pr.Name='IseeIt'; //name of project
         pr.Start_Date__c= date.today()`
         pr.Description__c='This Is To Do Kind Project';
         pr.End_Date__c=date.today()+5;
         insert pr;
    }

    public static void createTask(){ *//create todo method
         //Code to fetch data*
        Project__c pr = [Select Id from Project__c]; *//query for lookup relationship between project and todo*
         ToDo__c td = new ToDo__c();
         td.Project__c= pr.Id; *//fetchhing project id*
         td.Start_Date__c=date.today();
         td.Description__c='This is the first task';
         td.End_Date__c=date.today()+2;
         insert td;

    }

}

"System.QueryException: List has more than 1 row for assignment to SObject"
  because their are two project i have created  in the project object

Body:
Try this.

Project__c pr = [Select Id from Project__c];
    For this, you have to Select the query in where clause and put LIMIt 1 so that they give you only one record.
    Project__c pr = [Select Id from Project__c where name = 'IseeIt' LIMIT 1];