github.com/xgoffin/jenkins-library@v1.154.0/documentation/bin/createDocu.sh (about)

     1  #!/bin/bash
     2  
     3  d=$(dirname "$0")
     4  [ !  -z  "$d"  ] &&  d="$d/"
     5  
     6  WS_OUT="$(pwd)/documentation/jenkins_workspace"
     7  WS_IN=/workspace
     8  
     9  STEP_CALL_MAPPING_FILE_NAME=step_calls_mapping.json
    10  PLUGIN_MAPPING_FILE_NAME=plugin_mapping.json
    11  
    12  CALLS="${WS_OUT}/${STEP_CALL_MAPPING_FILE_NAME}"
    13  PLUGIN_MAPPING="${WS_OUT}/${PLUGIN_MAPPING_FILE_NAME}"
    14  
    15  for f in ${CALLS} ${PLUGIN_MAPPING}
    16  do
    17      [ -e "${f}" ] && rm -rf "${f}"
    18  done
    19  
    20  export CLASSPATH_FILE='target/cp.txt'
    21  mvn --batch-mode --show-version clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE}
    22  
    23  if [ "$?" != "0" ];then
    24      echo "[ERROR] maven test / build-classpath failed"
    25      exit 1
    26  fi
    27  
    28  if [ ! -f "${CLASSPATH_FILE}" ];then
    29      echo "[ERROR] Classpath file required for docu generation does not exist"
    30      exit 1
    31  fi
    32  
    33  # --in: is created by the unit tests. It contains a mapping between the test case (name is
    34  # already adjusted).
    35  # --out: Contains a transformed version. The calls to other pipeline steps are resolved in a
    36  # transitive manner. This allows us to report all Jenkins plugin calls (also the calls which
    37  # are performed by other pipeline steps. E.g.: each step includes basically a call to
    38  # handlePipelineStepErrors. The Plugin calls issues by handlePipelineStepErrors are also
    39  # reported for the step calling that auxiliar step).
    40  groovy  "${d}resolveTransitiveCalls" -in target/trackedCalls.json --out "${CALLS}"
    41  
    42  [ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; }
    43  
    44  docker run \
    45      -w "${WS_IN}" \
    46      --env calls="${WS_IN}/${STEP_CALL_MAPPING_FILE_NAME}" \
    47      --env result="${WS_IN}/${PLUGIN_MAPPING_FILE_NAME}" \
    48      -v "${WS_OUT}:${WS_IN}"  \
    49      ppiper/jenkinsfile-runner \
    50          -ns \
    51          -f Jenkinsfile \
    52          --runWorkspace /workspace
    53  
    54  [ -f "${PLUGIN_MAPPING}" ] || { echo "Result file containing step to plugin mapping not found (${PLUGIN_MAPPING})."; exit 1;  }
    55  
    56  groovy -cp "target/classes:$(cat $CLASSPATH_FILE)" "${d}createDocu" "${@}"