[ 
https://issues.apache.org/jira/browse/MWRAPPER-133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17845700#comment-17845700
 ] 

Ashley Scopes edited comment on MWRAPPER-133 at 5/12/24 11:57 AM:
------------------------------------------------------------------

We had the same issue, which was unfortunate.

For us, we have a Groovy function that we reuse to inject our default Maven 
settings via the `withMaven` pipeline script plugin. To address this, we 
injected the fixed environment variables into the function.

{code:groovy}
// vars/withMavenConfig.groovy
void call(Closure closure) {
  withMaven(...) {
    withEnv(["MAVEN_ARGS='${env.MAVEN_CONFIG}'"]) {
      closure()
    }
  }
}
{code}
{code:groovy}
pipeline {
  agent { label "master" }
  environment { ... }
  stages {
    stage("Run") {
      steps {
        script {
          withMavenConfig {
            sh("./mvnw -B clean verify")
          }
        }
      }
    }
  }
}
{code}

This is far from ideal though...

That being said, I feel that maybe Apache shouldn't have just totally removed 
this, and instead deprecated it explicitly and made the wrapper log a warning 
when encountered this, as this caused a lot of issues for us.


was (Author: JIRAUSER291213):
We had the same issue, which was unfortunate.

For us, we have a Groovy function that we reuse to inject our default Maven 
settings via the `withMaven` pipeline script plugin. To address this, we 
injected the fixed environment variables into the function.

{code:groovy}
void withCommonMavenSettings(Closure closure) {
  withMaven(...) {
    withEnv(["MAVEN_ARGS='${MAVEN_CONFIG}'"]) {
      closure()
    }
  }
}
{code}

This is far from ideal though...

That being said, I feel that maybe Apache shouldn't have just totally removed 
this, and instead deprecated it explicitly and made the wrapper log a warning 
when encountered this, as this caused a lot of issues for us.

> MAVEN_CONFIG populated by Jenkins Maven Pipeline is no longer read,
> -------------------------------------------------------------------
>
>                 Key: MWRAPPER-133
>                 URL: https://issues.apache.org/jira/browse/MWRAPPER-133
>             Project: Maven Wrapper
>          Issue Type: Bug
>          Components: Maven Wrapper Scripts
>    Affects Versions: 3.3.0
>            Reporter: Rocher Suchard
>            Priority: Major
>
> Hello,
> Due to an update by Renovate in one of our project, I've seen some error 
> related to internal dependencies not being picked up by Maven : while we were 
> using a custom settings, it did not use it and was using Central instead of 
> our Artifactory.
> Upon analysis, it seems that Maven Pipeline define a MAVEN_CONFIG 
> environnement variable here : 
> https://github.com/jenkinsci/pipeline-maven-plugin/blob/8cfaff9c021c971d19e5469c553a86d954c05387/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution2.java#L400
> The MAVEN_CONFIG variables was used in our Maven 3.2.0 Wrapper script and 
> I've played around with the default value and type:
> {code:bash}
> $ mvn wrapper:3.3.0:wrapper -Dmaven=3.9.6
> # use scripts-only
> $ grep -r MAVEN_CONFIG mvnw mvnw.cmd .mvn/ 
> # nothing
> $ mvn wrapper:3.2.0:wrapper -Dmaven=3.9.6
> # use bin
> $ grep -r MAVEN_CONFIG mvnw mvnw.cmd .mvn/ 
> mvnw:MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
> mvnw:  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
> mvnw.cmd:  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %
> $ mvn wrapper:3.3.0:wrapper -Dmaven=3.9.6 -Dtype=bin
> ...
> [INFO] Unpacked bin type wrapper distribution 
> org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:3.3.0
> [INFO] Configuring .mvn/wrapper/maven-wrapper.properties to use Maven 3.9.6 
> and download from https://repo.maven.apache.org/maven2
> ...
> $ grep -r MAVEN_CONFIG mvnw mvnw.cmd .mvn/
> mvnw:MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
> mvnw:  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
> mvnw.cmd:  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
> {code}
> Is there a way to do the same for the script-only if this is to be the 
> default ?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to