Skip to content

Jenkinsfile: Fix sysroot index file generation

For a long time we had a race in the sysroot index files generation that sometimes caused one of the links contained there to point to the wrong architecture, for instance the armhf index pointing to arm64.

Commit a221b5f4 was an attempt to fix it, but didn't improve the situation. Hovewer, it gave us some additional output that we could use to reason a bit more about the issue.

For instance, the v2019 20191122.0 job has this in the logs at https://jenkins.apertis.org/view/apertis-v2019/job/apertis-v2019/job/images/job/debos-image-build/140/consoleText:

[Pipeline] echo
sysroot sysroot/v2019/sysroot-apertis-v2019-armhf
version=v2019 20191122.0
url=https://images.apertis.org/daily/v2019/20191122.0/arm64/sysroot/sysroot-apertis-v2019-arm64-20191122.0.tar.gz

The relevant code:

sysrootname = "sysroot-${osname}-${release}-${architecture}-${env.PIPELINE_VERSION}"
sysrooturl = "${image_url_prefix}/daily/${release}/${env.PIPELINE_VERSION}/${architecture}/sysroot/${sysrootname}.tar.gz"
sh(script: """
    cd ${PIPELINE_VERSION}/${architecture}/${type}
    debos ${debosarguments} \
      --show-boot \
      -t architecture:${architecture} \
      -t ospack:ospack_${release}-${architecture}-${type}_${PIPELINE_VERSION} \
      -t sysroot:${sysrootname} \
      ${WORKSPACE}/${osname}-sysroot.yaml; \
    """)

// Generate sysroot metadata
def metadata_file = "sysroot/${release}/sysroot-${osname}-${release}-${architecture}"
def metadata_contents = "version=${release} ${PIPELINE_VERSION}\nurl=${sysrooturl}\n"
echo "sysroot ${metadata_file}\n${metadata_contents}"
writeFile file: metadata_file, text: metadata_contents

From the output we can conclude that metadata_file is correct, while metadata_contents has the wrong arch, which comes from sysrooturl.

Note the lack of def before sysrooturl. That means that Groovy is creating a global variable. So every time the stage is run, the shared global variable is overridden: in this case, the stage is run for armhf first and before it reaches the Generate sysroot metadata section the arm64 stage is run as well, overridding sysrooturl.

Adding a def there should finally fix this longstanding issue.

See https://phabricator.apertis.org/T6317 for more details.

Edited by Andrej Shadura

Merge request reports

Loading