Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Stuart Rowe
    @stuartrowe
    Then I use the env mock like:
     getPipelineMock("env.getProperty")(envKey) >> envValue
    Jerry Wiltse
    @solvingj
    i see. I'll make a note of your examples here, thanks
    I think this example is a great illustration of my point which is that... this could theoretically be made a lot less verbose and ceremonial
    The process of actually instantiating a CpsScriptat runtime is an extremely complex process, but mocking a number of super common things like env and params is a fairly universal need for anyone trying to unit test.
    Mocking things like the causes chain is pretty difficult for users, and it would be difficult to solve it in a general way as well
    Jerry Wiltse
    @solvingj
    But it seems like the jenkins libraries could potentially provide an alternate constructor and implementation in order to make it possible to manually instantiate an actual CpsScript object from simple Maps along with these extremely commonly used parts actually functional and working .
    @stuartrowe i can't remember why , but the second half of my .gdsl file (all the methods which require node context), are not showing in intellisense. Have you made that work? I added the CpsScript as the ctype here:
    //Steps that require a node context def nodeCtx = context(ctype: 'org.jenkinsci.plugins.workflow.cps.CpsScript')
    4 replies
    i really thought that fixed it in the past
    steven-terrana
    @steven-terrana

    @solvingj TBH from what i know of what you’re workin on, your needs are significantly more sophisticated than the vast majority of pipeline users where Jenkins-Spock is good enough ahah.

    But it’s all code. and Jenkins works through extensions that can be looked up. so yeah… if you can imagine a syntax it’s probably possible to make it possible.

    I’m actually a fan of just using the Jenkins test harness and saying “forget about mocking it. just run a real pipeline”

    the JTE test suite is a better way of testing JTE libraries than the test suite i have for the libraries i help maintain :joy:

    Jenkinsfile runner is also an interesting option for testing pipelines
    steven-terrana
    @steven-terrana

    one last thought is that even if you successfully mock it, there are some gotcha’s with the CPS transformation where your unit tests could pass only to fail during real pipeline execution.

    so you’d need to add the CPS transformers to compile the tests as well or something like that

    Jerry Wiltse
    @solvingj
    yes there seems to be good options at the ends of the spectrum, but not good options in the middle. Like, you can unit test a bunch of raw java/groovy, and you can unit test whole pipelines, but when you want to test non-trivial stuff which requires a bit of actual Jenkins classes, it's all corner cases.
    thanks for the feedback to all
    Mark Jaffe
    @Jaff

    I’ve been posting in #jenkins channel, will try here. I am trying to convert a recipe from:

    docker run --rm --privileged \
      -v $PWD:/go/src/github.com/user/repo \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -w /go/src/github.com/user/repo \
      -e GITHUB_TOKEN \
      -e DOCKER_USERNAME \
      -e DOCKER_PASSWORD \
      -e DOCKER_REGISTRY \
      goreleaser/goreleaser release

    to declarative pipeline:

          agent { docker {
             image 'goreleaser/goreleaser'
             label 'docker'
             args '-v $PWD:/go/src/github.com/user/repo -w /go/src/github.com/user/repo --entrypoint='
             } 
          }

    but I am getting an error, since $PWD is not resolved as such. What can I use?

    Liam Newman
    @bitwiseman
    @Jaff I’m not sure of the top of my head. Maybe
    -v $WORKSPACE:/go/src/github.com/user/repo?
    Mark Jaffe
    @Jaff
    @bitwiseman Nope, that does not get resolved in this context.
    Liam Newman
    @bitwiseman
    @Jaff Where do you expect $PWD to be in this case?
    @Jaff It looks like $HOME is defined at least, but that doesn’t match what you want, right?
    Mark Jaffe
    @Jaff
    I’m trying a different approach now, running a shell script on a generic docker image containing aws-cli & gnupg
    Carlos OKieffe
    @cokieffebah
    not sure if it matters but ... should it be a double quoted string "..." to do interpolation
    Mark Jaffe
    @Jaff
    How do I ensure my declarative-pipeline steps are actually running in the docker container I specify? I have declared in the environment block:
    HOME = /home/jenkins yet when the script runs and I have printenv invoked, I see HOME=/tmp
    Liam Newman
    @bitwiseman
    This is more of a question for jenkinsci/jenkins channel.
    emmedierre
    @emmedierre

    Hi
    I note that with multibranch pipeline the workspace folder is cut
    for example a project named:
    Sample09-Netbeans-MultiBranch-Pipeline-Maven-Svn

    that comes from a subversion repository like
    https://my-favourite-repo/svn/ProjectsJava/DevOps/Jenkins/Test/test-jenkins-java-maven-multibranch/

    with a project folder like
    D:\ProjectsJava\DevOps\Jenkins\Test\test-jenkins-java-maven-multibranch\trunk\myproject

    produce a workspace folder like this
    peline-Maven-Svn_trunk_myproject

    other types of project doesn't have this problem

    i found a workaround using a customWorkspace, but when i use it maven doesn't file
    the settings.xml file and i must specify it in the maven command

    There is a way to configure the workspace folders of a job outside the jenkinsfile ?

    Liam Newman
    @bitwiseman
    @emmedierre This is more of a question for jenkinsci/jenkins channel.
    soukainakhalkhouli
    @soukainakhalkhouli
    hi everyone ,
    image.png
    image.png
    i 'm working in jenkins pipeline and i got this error can you help me please to solve my problem ?
    Mark Waite
    @MarkEWaite
    That message usually indicates that the Linux computer where you're trying to run the xvfb (X Windows Virtual Framebuffer) plugin does not have xvfb installed. The xvfb package is usually an optional; package provided by the operating system (CentOS, Debian, Red Hat, SUSE, Ubuntu, etc.)
    ishumurali
    @ishumurali:matrix.org
    [m]
    Hello All, in jenkins file we are using findbugs in sonarqube stage "findbugs pattern: "**/findbugs-result.xml"" it shows error in jenkins No such DSL method "findbugs"
    1 reply
    Could you please help
    pgerell
    @pgerell

    Hi. I am trying to create multiple jobs for a project using the same pipeline with slight variations based on environment variables.
    I have a pipeline that looks like the following.
    I would like to refactor out the environments block to be able to provide different environments for each job, but sharing the actual pipeline definitions.
    I have looked into the Jenkins Templating Engine, but not yet been able to do what I want.

    Maybe environment variables are not the correct approach. I have also tried parameters without success.

    pipeline {
        agent any
        environment {
            CC = '/usr/bin/gcc'
            BUILD_TYPE = 'Release'
        }
        stages {
            stage('Build') {
                steps {
                    cmakeBuild buildDir: 'build', buildType: "${env.BUILD_CONF}", installation: 'InSearchPath', sourceDir: 'src', steps: [[args: '-j4']]
                }
            }
            stage('Test') {
                steps {
                    sh './test.sh'
                }
            }
        }
    }
    4 replies
    Mario Jauvin
    @marioja
    Good night. Does anyone know how to configure the agent when using shared libraries. I want to be able to either select agent any or agent { label “$agent”}?. You can see a good description of my problem in this stackoverflow:
    https://stackoverflow.com/a/65027879?noredirect=1
    It was suggested by another user in another group that agent label empty string would possibly achieve the same results as agent any
    Liam Newman
    @bitwiseman
    @marioja Yes. label "" is the same as any.
    rajroyce1212
    @rajroyce1212

    Hi
    I need to pass the Github URL and Password from Credentials Id using Pipeline Script.
    I tried to Parameter for URL and its was working Fine but I can't pass with Credentials ID Dynamic.But When Pass that same ID statically it is Working.
    Can anyone help on this

    git branch: 'master', url: '$github', credentialsId: '${params.credid}'

    1 reply
    dduportal
    @dduportal:matrix.org
    [m]
    Hello there 👋 as a follow up of the recent UX SIG meetings, I would want to participate to the next Pipeline SIG meeting to bring a subject, but I want to be sure:
    • That today's Pipeline SIG meeting is maintained (It is in the community agenda, but never harm to ask)?
    • That it's ok to bring a new subject (or maybe we could start discussing on a written support here, on an issue, etc.)?
    • As the subject is "Allowing multiple pipeline for a given repository, ala. GH Actions", maybe this feature request as already been discussed/raised before (I'm fighting with JIRA search to scout previous issues abou this topic): is it ok to discuss this?
      => Don't hesitate to throw me away if you feel likeI'm not doing things correctly, or if it is not the right time/context of course
    speechkey
    @speechkey
    Hi folks, I'm wondering if its possible to use git reference repositories for branch indexing (scan multibranch pipeline), otherwise using ref repo in a multibranch pipeline makes in my oppinion not really a big sense.
    2 replies
    Martin Jainta
    @mjainta

    Hello there :wave: If I am wrong here, please let me know. I did not get an answer yet in the general Jenkins gitter group and thought I might try it in here as well.

    Currently, I am researching how to best migrate our matrix job to a pipeline matrix. I get simple examples running, but our specific use case is that the matrix I want to migrate consists of ~1500 sub builds. That is because we got 2 axes: One for the executor label, and the other one is dynamic, with an entry for each test file we have.
    The goal of this is to parallelize our test runs.

    Sadly I have the feeling that with pipelines, I am either breaking boundaries (declarative can have 250 entries per axis maximum) or it is kinda slow (scripted pipeline, found tickets in that regard, for example https://issues.jenkins.io/browse/JENKINS-47724)

    What is the best practice for such a use case in your experience?

    2 replies
    Mats Faugli
    @fowlie
    Hello! Hope this is the right forum to ask. I have a .NET agent based on the official Microsoft docker image. When running a pwsh step with a simple Echo command it fails with Program 'pwsh' failed to run: No such file or directory, even though running the pwsh binary from a sh step works fine. Any clues?
    dduportal
    @dduportal:matrix.org
    [m]
    I might not ask in the correct channel, my apologies if I don't, but I have a use case which sounds not "general support": I have a pipeline on which I want to implement a circuit breaker: “Try 3 times my build steps, with a timeout of 10 min each - e.g. the pipeline will be aborted in 30 min in the worst case, and my build step should NOT take more than 10 min or it means there is an error”. I naively thought that combining retry and timeout would work but in fact it does not: jenkinsci/workflow-basic-steps-plugin#143 => for the time being, timeout inside retry does not retry: when the 1st timeout is reached, the whole job is aborted. Confirmed in https://issues.jenkins.io/browse/JENKINS-51454?focusedCommentId=381283&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-381283 => Is there another “method” to implement the circuit breaker case or do I have to go down a pipeline library method for this?
    Liam Newman
    @bitwiseman
    @dduportal:matrix.org Hm. What are the build steps you are running? If sh then you could use a timeout inside the shell: https://stackoverflow.com/questions/9954794/execute-a-shell-function-with-timeout
    I don't know of another way to do this off hand. Timeout is meant as a guard rail not flow control.
    pgerell
    @pgerell
    Does anyone has any experience using Environment Modules with Jenkins pipelines?
    I know I could have module load commands within sh steps, but I would like to have a way to modify the environment for all stages within the pipeline. E.g. load a specific cmake version and have that version called when having a cmakeBuild step in a later stage.
    ravi83
    @ravi83:matrix.org
    [m]
    Does anyone has any experience using Dynamic agent (Specially alpine linux)
    ravi83
    @ravi83:matrix.org
    [m]
    I have created/build a container with alpine Linux and set few env variables accordingly and it reflecting fine in the container if I see the output of "env" command, However, If I use the same in the Jenkins pipeline those env variables are not reflecting and Job is failing. But the same kind of configuration is working fine with the centos image
    fugkco
    @fugkco:matrix.org
    [m]
    Ravikumar K A: you probably want to ask in #jenkinsci_jenkins:gitter.im
    Hi all, I was referred here from one of the other channels. I wonder is https://issues.jenkins.io/browse/JENKINS-43749 part of this SIG? If so, has there been any thought or something into this ticket? This ticket is the only thing holding us back from removing Job-DSL which is inferior from using multiple Jenkinsfiles (lot's of issues that we've discovered). I'd be happy to talk about this feature request too. Personally I think it is critical to compete with the likes of GitHub workflow.
    Mark Waite
    @MarkEWaite
    @fugkco:matrix.org the same idea was being discussed by @dduportal:matrix.org in the Jenkins UX meeting. I believe he's interested as well.
    dduportal
    @dduportal:matrix.org
    [m]
    Thanks a lot fugkco for mentioning it. As @MarkEWaite said, it was a subject mentioned on the UX SIG, and any help is welcome to lead the subject for the pipeline authoring here.